/// <summary> /// Gets the user specified by the user name, or null if no such user exists. /// </summary> /// <param name="userName"></param> /// <param name="persistenceContext"></param> /// <returns></returns> private static User GetUser(string userName, IPersistenceBrokerFactory persistenceContext) { var criteria = new UserSearchCriteria(); criteria.UserName.EqualTo(userName); // use query caching here to make this fast (assuming the user table is not often updated) var users = persistenceContext.GetBroker <IUserBroker>().Find( criteria, new SearchResultPage(0, 1), new EntityFindOptions { Cache = true }); // bug #3701: to ensure the username match is case-sensitive, we need to compare the stored name to the supplied name // returns null if no match return(CollectionUtils.SelectFirst(users, u => u.UserName == userName)); }
/// <summary> /// Gets the user specified by the user name, or null if no such user exists. /// </summary> /// <param name="userName"></param> /// <param name="persistenceContext"></param> /// <returns></returns> private static User GetUser(string userName, IPersistenceBrokerFactory persistenceContext) { var criteria = new UserSearchCriteria(); criteria.UserName.EqualTo(userName); // use query caching here to make this fast (assuming the user table is not often updated) var users = persistenceContext.GetBroker<IUserBroker>().Find( criteria, new SearchResultPage(0, 1), new EntityFindOptions { Cache = true }); // bug #3701: to ensure the username match is case-sensitive, we need to compare the stored name to the supplied name // returns null if no match return CollectionUtils.SelectFirst(users, u => u.UserName == userName); }