本文整理汇总了C#中IDataAccess.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IDataAccess.Select方法的具体用法?C# IDataAccess.Select怎么用?C# IDataAccess.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataAccess
的用法示例。
在下文中一共展示了IDataAccess.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUser
public static User GetUser(IDataAccess dataAccess, int userId)
{
if(dataAccess == null)
throw new ArgumentNullException("dataAccess");
return dataAccess.Select<User>(DATA_ENTITY_USER, new Condition("UserId", userId)).FirstOrDefault();
}
示例2: GetUserId
public static bool GetUserId(IDataAccess dataAccess, string identity, string @namespace, out int userId)
{
if(dataAccess == null)
throw new ArgumentNullException("dataAccess");
if(string.IsNullOrWhiteSpace(identity))
throw new ArgumentNullException("identity");
var conditions = MembershipHelper.GetUserIdentityConditions(identity, @namespace);
var record = dataAccess.Select<IDictionary<string, object>>(MembershipHelper.DATA_ENTITY_USER, conditions, "!, UserId").FirstOrDefault();
var result = record != null && record.Count > 0 && record.ContainsKey("UserId");
userId = 0;
if(result)
userId = Zongsoft.Common.Convert.ConvertValue<int>(record["UserId"]);
return result;
}
示例3: GetPasswordCore
private static int? GetPasswordCore(IDataAccess dataAccess, ICondition condition, out byte[] password, out byte[] passwordSalt, out bool isApproved, out bool isSuspended)
{
if(dataAccess == null)
throw new ArgumentNullException("dataAccess");
if(condition == null)
throw new ArgumentNullException("condition");
password = null;
passwordSalt = null;
isApproved = false;
isSuspended = false;
//从数据引擎中获取指定条件的用户密码数据
var dictionary = dataAccess.Select<IDictionary<string, object>>(MembershipHelper.DATA_ENTITY_USER, condition, "!, UserId, Password, PasswordSalt, Approved, Suspended").FirstOrDefault();
if(dictionary == null || dictionary.Count < 1)
return null;
object value;
if(dictionary.TryGetValue("Approved", out value))
isApproved = Zongsoft.Common.Convert.ConvertValue<bool>(value);
if(dictionary.TryGetValue("Suspended", out value))
isSuspended = Zongsoft.Common.Convert.ConvertValue<bool>(value);
object storedPassword;
object storedPasswordSalt;
dictionary.TryGetValue("Password", out storedPassword);
dictionary.TryGetValue("PasswordSalt", out storedPasswordSalt);
password = storedPassword as byte[];
passwordSalt = storedPasswordSalt as byte[];
object result;
if(dictionary.TryGetValue("UserId", out result))
return Zongsoft.Common.Convert.ConvertValue<int?>(result, () => null);
return null;
}