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