Пример #1
0
        public T Pick <T>(Expression <Func <T, bool> > where) where T : IEntity
        {
            var t = GetAll <T>().SingleOrDefault(where.Compile());

            if (t == null)
            {
                t = MongoEntity.Get <T>(where);
            }
            Add <T>(t);
            return(t);
        }
Пример #2
0
        public T Pick <T>(string id) where T : IEntity
        {
            var t = getContainer <T>().SingleOrDefault(e => e.Id == id);

            if (t == null)
            {
                t = MongoEntity.Get <T>(id);
            }
            Add <T>(t);
            return(t);
        }
Пример #3
0
 public List <T> GetAll <T>() where T : IEntity
 {
     if (NeedToFreshAll <T>())
     {
         var all  = getContainer <T>();
         var refs = _dbRef.Where(r => !all.Exists(e => e.Id == r.Id));
         var ids  = refs.Select <MongoDBRef, string>(r => r.Id.ToString()).ToArray();
         all.AddRange(MongoEntity.Select <T>(t => ids.Contains(t.Id)));
         return(all);
     }
     return(getContainer <T>());
 }