public IQueryable <E> GetByMaxCreateTime(IQueryable <E> list, DateTime create_at_max) { if (typeof(IGetting).IsAssignableFrom(typeof(E))) { Expression <Func <E, bool> > node = (E q) => ((IGetting)q).CreateTime <= create_at_max; node = (Expression <Func <E, bool> >)RemoveCastsVisitor.Visit(node); return(Queryable.Where <E>(list, node)); } return(list); }
public IQueryable <E> GetSinceId(int sinceId, IQueryable <E> list) { if (typeof(IGetting).IsAssignableFrom(typeof(E))) { Expression <Func <E, bool> > node = (E q) => ((IGetting)q).Id >= sinceId; node = (Expression <Func <E, bool> >)RemoveCastsVisitor.Visit(node); return(Queryable.Where <E>(list, node)); } return(list); }
public virtual IQueryable <T> GetActive(Expression <Func <T, bool> > predicate) { if (typeof(IActivable).IsAssignableFrom(typeof(T))) { var sourceQuerable = _dbSet.Where <T>(predicate); Expression <Func <T, bool> > checkActiveExpress = (T t) => ((IActivable)t).Active; var cleanCheckActiveExpress = (Expression <Func <T, bool> >)RemoveCastsVisitor.Visit(checkActiveExpress); return(sourceQuerable.Where(cleanCheckActiveExpress)); } return(this.Get(predicate)); }
public virtual Task <T> FirstOrDefaultActiveAsync(Expression <Func <T, bool> > predicate) { if (typeof(IActivable).IsAssignableFrom(typeof(T))) { var sourceQuerable = _dbSet.Where <T>(predicate); Expression <Func <T, bool> > checkActiveExpress = (T t) => ((IActivable)t).Active; var cleanCheckActiveExpress = (Expression <Func <T, bool> >)RemoveCastsVisitor.Visit(checkActiveExpress); return(sourceQuerable.FirstOrDefaultAsync(cleanCheckActiveExpress)); } return(this.FirstOrDefaultAsync(predicate)); }
// public JsonSerializerSettings ToJson(string fields) //{ // var jsonResolver = new PropertyRenameAndIgnoreSerializerContractResolver(); // var jsonProperty = _model.GetType().GetProperties() // .SelectMany(p => p.GetCustomAttributes(typeof(JsonPropertyAttribute)) // .Cast<JsonPropertyAttribute>()) // .Select(jp => jp.PropertyName); // if (!string.IsNullOrEmpty(fields)) // { // foreach (var item in jsonProperty) // { // if (!fields.Contains(item)) // { // jsonResolver.IgnoreProperty(typeof(AgencyServiceModel), item); // } // } // } // var serializerSettings = new JsonSerializerSettings // { // ContractResolver = jsonResolver // }; // return serializerSettings; //} public IQueryable <E> GetByIds(List <int> ids, IQueryable <E> list) { if (typeof(IGetting).IsAssignableFrom(typeof(E))) { Expression <Func <E, bool> > node = (E q) => ids.Contains(((IGetting)q).Id); node = (Expression <Func <E, bool> >)RemoveCastsVisitor.Visit(node); return(Queryable.Where <E>(list, node)); } return(list); }
public virtual TEntity FirstOrDefaultActive() { if (this.IsEntityActivable) { Expression <Func <TEntity, bool> > getActive = q => ((IActivable)q).Active; getActive = (Expression <Func <TEntity, bool> >)RemoveCastsVisitor.Visit(getActive); return(this.dbSet.FirstOrDefault(getActive)); } else { return(this.FirstOrDefault()); } }
public virtual IQueryable <TEntity> GetActive() { if (typeof(IActivable).IsAssignableFrom(typeof(TEntity))) { Expression <Func <TEntity, bool> > getActive = q => ((IActivable)q).Active; getActive = (Expression <Func <TEntity, bool> >)RemoveCastsVisitor.Visit(getActive); return(this.Get().Where(getActive)); } else { return(this.Get()); } }
public Task <TEntity> FirstOrDefaultActiveAsync(Expression <Func <TEntity, bool> > predicate) { if (typeof(IActivable).IsAssignableFrom(typeof(TEntity))) { Expression <Func <TEntity, bool> > getActive = q => ((IActivable)q).Active; getActive = (Expression <Func <TEntity, bool> >)RemoveCastsVisitor.Visit(getActive); return(this.dbSet.Where(predicate).FirstOrDefaultAsync(getActive)); } else { return(this.FirstOrDefaultAsync(predicate)); } }