public virtual TEntity GetSingle(
            Expression <Func <TEntity, bool> > filter = null,
            string includeProperties = "", object id = null, int?version = null)
        {
            if (version == null)
            {
                IQueryable <TEntity> query = dbSet;

                if (filter != null)
                {
                    query = query.Where(filter);
                }

                foreach (var includeProperty in includeProperties.Split
                             (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    query = query.Include(includeProperty);
                }
                if (query != null)
                {
                    return(query.FirstOrDefault());
                }
            }
            else
            {
                return(logger.GetByIdAndVersion(id.ToString(), version.GetValueOrDefault()));
            }
            return(null);
        }
Esempio n. 2
0
 public virtual T Find(params object[] keyValues)
 {
     if (IsParentInPreview)
     {
         // todo , try to find a way to put this logic in to a factory
         //currently park Detaiul is hard coded
         var logger = new DataVersionCreator <TP>();
         return(logger.GetAllChildrenByVersion <T>(_version, getChildren).FirstOrDefault(t => findId(t).Equals((TID)keyValues.First())));
     }
     else
     {
         var logger = new DataVersionCreator <T>();
         return(logger.GetByIdAndVersion(keyValues[0].ToString(), _version));
     }
 }