Пример #1
0
 public IUserDefinition ById(string id)
 {
     return(TwoLevelCache.Get <UserDefinition>("UserByID_" + id, TimeSpan.Zero, TimeSpan.FromDays(1), fld.GenerationKey, () => {
         using (var connection = SqlConnections.NewByKey("Default"))
             return GetFirst(connection, new Criteria(fld.UserId) == Int32.Parse(id));
     }));
 }
Пример #2
0
        public IUserDefinition ByUsername(string username)
        {
            if (username.IsEmptyOrNull())
                return null;

            return TwoLevelCache.Get<UserDefinition>("UserByName_" + username.ToLowerInvariant(), 
                TimeSpan.Zero, TimeSpan.FromDays(1), fld.GenerationKey, () =>
            {
                using (var connection = SqlConnections.NewByKey("Default"))
                    return GetFirst(connection, new Criteria(fld.Username) == username);
            });
        }