예제 #1
0
 private static LockboxPin GetObject(long id)
 {
     lock (TypeLocker)
     {
         LockboxPin obj;
         if (Manager.Settings.CacheData)
         {
             if (_objStore.TryGetValue(id, out obj))
             {
                 return(obj);
             }
         }
         using (var session = SessionFactory.OpenSession())
         {
             obj = session.Get <LockboxPin>(id);
         }
         if (obj != null)
         {
             obj.IsNew = false;
             if (Manager.Settings.CacheData)
             {
                 _objStore.Add(id, obj);
             }
             return(obj);
         }
         obj = new LockboxPin()
         {
             Id = id
         };
         if (Manager.Settings.CacheData)
         {
             _objStore.Add(id, obj);
         }
         return(obj);
     }
 }
예제 #2
0
        private static LockboxPin GetObject(long id)
        {
            lock (TypeLocker)
            {

                LockboxPin obj;
                if (Manager.Settings.CacheData)
                {
                    if (_objStore.TryGetValue(id, out obj))
                    {
                        return obj;
                    }
                }
                using (var session = SessionFactory.OpenSession())
                {
                    obj = session.Get<LockboxPin>(id);
                }
                if (obj != null)
                {
                    obj.IsNew = false;
                    if (Manager.Settings.CacheData)
                        _objStore.Add(id, obj);
                    return obj;
                }
                obj = new LockboxPin()
                {
                    Id = id
                };
                if (Manager.Settings.CacheData)
                    _objStore.Add(id, obj);
                return obj;
            }
        }