public IQueryable <TEntity> GetModel(System.Linq.Expressions.Expression <Func <TEntity, bool> > predicate) { return(GetModel().Where(predicate)); }
public List <human_file> FindAllHumanFileByState(int pageInxex, int pageSize, out int count, System.Linq.Expressions.Expression <Func <human_file, bool> > where) { return(dao.FindAllHumanFileByState(pageInxex, pageSize, out count, where)); }
public IEnumerable <T> Get(System.Linq.Expressions.Expression <Func <T, bool> > predicate) { return(_unitOfWork.Context.Set <T>().Where(predicate).AsEnumerable <T>()); }
protected override IEnumerable <TAggregateRoot> DoFindAll(ISpecification <TAggregateRoot> specification, System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> > sortPredicate, SortOrder sortOrder) { var dbQuery = this._efContext.Context.Set <TAggregateRoot>() .Where(specification.IsSatisfiedBy); if (sortPredicate != null) { switch (sortOrder) { case SortOrder.Ascending: return(dbQuery.OrderBy(sortPredicate.Compile()).ToList()); case SortOrder.Descending: return(dbQuery.OrderByDescending(sortPredicate.Compile()).ToList()); default: break; } } return(dbQuery.ToList()); }
public SystemCountryCodePoco GetSingle(System.Linq.Expressions.Expression <Func <SystemCountryCodePoco, bool> > where, params System.Linq.Expressions.Expression <Func <SystemCountryCodePoco, object> >[] navigationProperties) { IQueryable <SystemCountryCodePoco> pocos = GetAll().AsQueryable(); return(pocos.Where(where).FirstOrDefault()); }
protected override IEnumerable <TAggregateRoot> DoFindAll(ISpecification <TAggregateRoot> specification, System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> > sortPredicate, SortOrder sortOrder, params System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> >[] eagerLoadingProperties) { var dbSet = this._efContext.Context.Set <TAggregateRoot>(); IEnumerable <TAggregateRoot> queryable = null; // dealing with eagerLoadingProperties if (eagerLoadingProperties != null && eagerLoadingProperties.Length > 0) { var eagerLoadingPath = ""; foreach (var eagerLoadingProperty in eagerLoadingProperties) { eagerLoadingPath = this.GetEagerLoadingProperty(eagerLoadingProperty); dbSet.Include(eagerLoadingPath); } queryable = dbSet.Where(specification.IsSatisfiedBy); } else { queryable = dbSet.Where(specification.IsSatisfiedBy); } // dealing with sorting if (sortPredicate != null) { switch (sortOrder) { case SortOrder.Ascending: return(queryable.OrderBy(sortPredicate.Compile()).ToList()); case SortOrder.Descending: return(queryable.OrderByDescending(sortPredicate.Compile()).ToList()); default: break; } } // no sorting aruguments return(queryable.ToList()); }
protected override IEnumerable <TAggregateRoot> DoGetAll(ISpecification <TAggregateRoot> specification, System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> > sortPredicate, SortOrder sortOrder) { var results = this.DoFindAll(specification, sortPredicate, sortOrder); if (results == null || !results.Any()) { return(null); } return(results); }
/// <summary> /// 获取where表达式 /// </summary> /// <param name="s1"></param> /// <returns></returns> public static System.Linq.Expressions.Expression <Func <T, bool> > GetWhereLambda(S s1 = null, System.Linq.Expressions.Expression <Func <T, bool> > ExAdd = null) { ParameterExpression param = Expression.Parameter(typeof(T), "c"); Expression Iwhere = null; if (ExAdd != null) { param = ExAdd.Parameters[0]; Iwhere = ExAdd.Body; } bool HasValue = false; foreach (System.Reflection.PropertyInfo pinfo in s1.GetType().GetProperties()) { if (!pinfo.CanRead) { continue; } object Selvalue = pinfo.GetValue(s1, null); if (Selvalue == null) { continue; } object ob = pinfo.GetCustomAttributes(typeof(SearchAttribute), false).FirstOrDefault(); string TableName = null; string ColName = pinfo.Name; Symbol symbl = Symbol.等于; if (ob != null) { SearchAttribute dA = (SearchAttribute)ob; TableName = dA.TableName; ColName = dA.BaseName; symbl = dA.Symbol; } if (symbl == Symbol.无效) { continue; } object op = pinfo.GetCustomAttributes(typeof(ExpressAttrInterface), true).FirstOrDefault(); Expression left = null; if (op != null) { left = (op as ExpressAttrInterface).GetExpression(param, typeof(T)); } else { if (string.IsNullOrEmpty(TableName)) { left = Expression.Property(param, typeof(T).GetProperty(ColName)); } else { left = Expression.Property(Expression.Property(param, typeof(T).GetProperty(TableName)), typeof(T).GetProperty(TableName).PropertyType.GetProperty(ColName)); } } Expression where2 = whereSymbol(symbl, left, null, Selvalue); if (Iwhere == null) { Iwhere = where2; } else { Iwhere = Expression.And(Iwhere, where2); } HasValue = true; } if (Iwhere == null || HasValue == false) { Iwhere = Expression.Constant(true); } return(Expression.Lambda <Func <T, bool> >(Iwhere, param)); }
public override IEnumerable <T> FindAll <T>(System.Linq.Expressions.Expression <Func <T, bool> > criteria, int offset = 0, int limit = 0, System.Linq.Expressions.Expression <Func <T, object> > orderBy = null) { try { if (_strategy == FailoverStrategy.Failback) { Failback(); } return(_current.FindAll(criteria, offset, limit, orderBy)); } catch (Exception ex) { if (_logger != null) { _logger(ex); } if (_strategy == FailoverStrategy.ReplicationOnly) { throw; } Failover(); return(_current.FindAll(criteria, offset, limit, orderBy)); } }
public static void Update <TEntity>(this System.Data.Linq.Table <TEntity> source, System.Linq.Expressions.Expression <Func <TEntity, int, bool> > predicate, object NewValues) where TEntity : class { }
public T Get(System.Linq.Expressions.Expression <Func <T, bool> > p) { return(_database.GetCollection <T>(typeof(T).Name).Find <T>(p).FirstOrDefault()); }
public static int Delete <TEntity>(this System.Data.Linq.Table <TEntity> source, System.Linq.Expressions.Expression <Func <TEntity, int, bool> > predicate) where TEntity : class { System.Data.Linq.DataContext dc = source.Context; System.Data.Common.DbCommand c = dc.GetCommand(source.Where(predicate)); return(Delete(c)); }
public IQueryable <TEntity> GetModel(Action <IRepositories.Commons.IOrderable <TEntity> > orderBy, System.Linq.Expressions.Expression <Func <TEntity, bool> > predicate) { var queryable = GetModel().Where(predicate).AsQueryable(); var linq = new Orderable <TEntity>(queryable); orderBy(linq); return(linq.Queryable); }
public TEntity Find(System.Linq.Expressions.Expression <Func <TEntity, bool> > predicate) { return(GetModel().FirstOrDefault(predicate)); }
public virtual List <T> List(System.Linq.Expressions.Expression <Func <T, bool> > predicate) { var list = DbSet.Where(predicate).ToList(); return(list); }
public T Find <T>(System.Linq.Expressions.Expression <Func <T, bool> > predicate) where T : class { return(GetRepository <T>().Find(predicate)); }
protected override IEnumerable <TAggregateRoot> DoFindAll(ISpecification <TAggregateRoot> specification, System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> > sortPredicate, SortOrder sortOrder, int pageNumber, int pageSize) { if (pageNumber <= 0) { throw new ArgumentOutOfRangeException(nameof(pageNumber), pageNumber, "The pageNumber is one-based and should be larger than zero."); } if (pageSize <= 0) { throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The pageSize is one-based and should be larger than zero."); } var dbQuery = this._efContext.Context.Set <TAggregateRoot>() .Where(specification.IsSatisfiedBy); var skip = (pageNumber - 1) * pageSize; var take = pageSize; if (sortPredicate != null) { switch (sortOrder) { case SortOrder.Ascending: return(dbQuery.OrderBy(sortPredicate.Compile()).Skip(skip).Take(take).ToList()); case SortOrder.Descending: return(dbQuery.OrderByDescending(sortPredicate.Compile()).Skip(skip).Take(take).ToList()); default: break; } } return(dbQuery.Skip(skip).Take(take).ToList()); }
public int Count <T>(System.Linq.Expressions.Expression <Func <T, bool> > predicate) where T : class { return(GetRepository <T>().Count(predicate)); }
protected override IEnumerable <TAggregateRoot> DoFindAll(ISpecification <TAggregateRoot> specification, System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> > sortPredicate, SortOrder sortOrder, int pageNumber, int pageSize, params System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> >[] eagerLoadingProperties) { if (pageNumber <= 0) { throw new ArgumentOutOfRangeException(nameof(pageNumber), pageNumber, "The pageNumber is one-based and should be larger than zero."); } if (pageSize <= 0) { throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The pageSize is one-based and should be larger than zero."); } var skip = (pageNumber - 1) * pageSize; var take = pageSize; var dbSet = this._efContext.Context.Set <TAggregateRoot>(); IEnumerable <TAggregateRoot> queryable = null; // dealing with eagerLoadingProperties if (eagerLoadingProperties != null && eagerLoadingProperties.Length > 0) { var eagerLoadingPath = ""; foreach (var eagerLoadingProperty in eagerLoadingProperties) { eagerLoadingPath = this.GetEagerLoadingProperty(eagerLoadingProperty); dbSet.Include(eagerLoadingPath); } queryable = dbSet.Where(specification.IsSatisfiedBy); } else { queryable = dbSet.Where(specification.IsSatisfiedBy); } // dealing with sorting if (sortPredicate != null) { switch (sortOrder) { case SortOrder.Ascending: return(queryable.OrderBy(sortPredicate.Compile()).Skip(skip).Take(take).ToList()); case SortOrder.Descending: return(queryable.OrderByDescending(sortPredicate.Compile()).Skip(skip).Take(take).ToList()); default: break; } } // no sorting arguments return(queryable.Skip(skip).Take(take).ToList()); }
public System.Linq.IQueryable <T> Where <T>(System.Linq.Expressions.Expression <Func <T, bool> > predicate) where T : class { return(GetRepository <T>().Filter(predicate)); }
protected override IEnumerable <TAggregateRoot> DoGetAll(ISpecification <TAggregateRoot> specification, System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> > sortPredicate, SortOrder sortOrder, int pageNumber, int pageSize, params System.Linq.Expressions.Expression <Func <TAggregateRoot, dynamic> >[] eagerLoadingProperties) { var results = this.DoFindAll(specification, sortPredicate, sortOrder, pageNumber, pageSize, eagerLoadingProperties); if (results == null || !results.Any()) { throw new ArgumentException("Aggregate not found."); } return(results); }
public IEnumerable <TEntity> Find(System.Linq.Expressions.Expression <Func <TEntity, bool> > predicate) { return(UOW.Context.Set <TEntity>().Where(predicate)); }
public IList <SystemCountryCodePoco> GetList(System.Linq.Expressions.Expression <Func <SystemCountryCodePoco, bool> > where, params System.Linq.Expressions.Expression <Func <SystemCountryCodePoco, object> >[] navigationProperties) { throw new NotImplementedException(); }
public List <T> SearchForLocalTable <T>(System.Linq.Expressions.Expression <Func <T, bool> > predicate, int toSkip, int toTake) where T : new() { return(_liteConnection.Table <T>().Where(predicate).Skip(toSkip).Take(toTake).ToList()); }
IEnumerator <TEntity> IRepository <TEntity> .Find(System.Linq.Expressions.Expression <Func <TEntity, bool> > predicate) { throw new NotImplementedException(); }
public List <T> SearchForLocalTable <T>(System.Linq.Expressions.Expression <Func <T, bool> > predicate, Dictionary <string, string> p) where T : new() { return(_liteConnection.Table <T>().Where(predicate).ToList()); //result = await MobileService.GetTable<T>().Take(1000).Where(predicate).WithParameters(parameters).IncludeTotalCount().ToListAsync(); //return _liteConnection.Table<T>().Where(predicate).Where(t=>t.id == ).ToList(); }
public bool ExistEntityBy(System.Linq.Expressions.Expression <Func <T, bool> > predicate) { return(_idbset.Where(predicate).Any()); }
public IQueryable <T> SearchForQuery <T>(System.Linq.Expressions.Expression <Func <T, bool> > predicate, Dictionary <string, string> parameters) { return(MobileService.GetTable <T>().Where(predicate).WithParameters(parameters).IncludeTotalCount().Query); }
public IQueryable <T> All(System.Linq.Expressions.Expression <Func <T, bool> > predicate) { IQueryable <T> query = _entities.Set <T>().Where(predicate); return(query); }
public abstract IEnumerable <T> FindBy(System.Linq.Expressions.Expression <Func <T, bool> > filter);