示例#1
0
        public IQueryable<T> All<T>(string[] includes = null) where T : class
        {
            if (includes != null && includes.Count() > 0)
            {
                var query = dbContext.Set<T>().Include(includes.First());
                foreach (var include in includes.Skip(1))
                    query = query.Include(include);
                return query.AsQueryable();
            }

            return dbContext.Set<T>().AsQueryable();
        }
 /// <summary>
 /// Returns a single object with a primary key of the provided id
 /// </summary>
 /// <remarks>Synchronous</remarks>
 /// <param name="id">The primary key of the object to fetch</param>
 /// <returns>A single object with the provided primary key or null</returns>
 public TObject Get(int id)
 {
     return(_context.Set <TObject>().Find(id));
 }