protected virtual IQueryable <TEntity> GetQueryable <TEntity>( Expression <Func <TEntity, bool> > filter = null, Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderBy = null, string includeProperties = null, int?skip = null, int?take = null) where TEntity : class { includeProperties = includeProperties ?? string.Empty; IQueryable <TEntity> query = context.Set <TEntity>(); if (filter != null) { query = query.Where(filter); } foreach (var includeProperty in includeProperties.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { query = query.Include(includeProperty); } if (orderBy != null) { query = orderBy(query); } if (skip.HasValue) { query = query.Skip(skip.Value); } if (take.HasValue) { query = query.Take(take.Value); } return(query); }
public virtual void Create <TEntity>(TEntity entity) where TEntity : class { context.Set <TEntity>().Add(entity); }