/// <summary>
/// 添加用户并返回当前用户的ID(output inserted.userId )
/// </summary>
/// <param name="username"></param>
/// <param name="password"></param>
/// <param name="age"></param>
/// <returns></returns>
public long UserAdd(string username, string password, int? age)
{
string sql = "insert into t_users(username,password,age) output inserted.userId values(@name,@pass,@age)";
object obj = SqlHelper.ExecuteScalar(sql, new SqlParameter("@name", username), new SqlParameter("@pass", password)
, new SqlParameter("@age", age == null ? (object)DBNull.Value : age));
return Convert.ToInt64(obj);
}
/// 添加用户并返回当前用户的ID(output inserted.userId )
/// </summary>
/// <param name="username"></param>
/// <param name="password"></param>
/// <param name="age"></param>
/// <returns></returns>
public long UserAdd(string username, string password, int? age)
{
string sql = "insert into t_users(username,password,age) output inserted.userId values(@name,@pass,@age)";
object obj = SqlHelper.ExecuteScalar(sql, new SqlParameter("@name", username), new SqlParameter("@pass", password)
, new SqlParameter("@age", age == null ? (object)DBNull.Value : age));
return Convert.ToInt64(obj);
}