public virtual IQueryState Accept(AggregateQueryExpression exp) { List <DbExpression> dbArguments = new List <DbExpression>(exp.Arguments.Count); foreach (Expression argument in exp.Arguments) { var arg = (LambdaExpression)argument; ScopeParameterDictionary scopeParameters = this._resultElement.ScopeParameters.Clone(arg.Parameters[0], this._resultElement.MappingObjectExpression); var dbArgument = GeneralExpressionVisitor.ParseLambda(arg, scopeParameters, this._resultElement.ScopeTables); dbArguments.Add(dbArgument); } DbAggregateExpression dbAggregateExp = new DbAggregateExpression(exp.ElementType, exp.Method, dbArguments); MappingFieldExpression mfe = new MappingFieldExpression(exp.ElementType, dbAggregateExp); ResultElement result = new ResultElement(this._resultElement.ScopeParameters, this._resultElement.ScopeTables); result.MappingObjectExpression = mfe; result.FromTable = this._resultElement.FromTable; result.AppendCondition(this._resultElement.Condition); AggregateQueryState state = new AggregateQueryState(result); return(state); }
IMappingObjectExpression VisistMapTypeSelector(Expression exp) { if (!MappingTypeSystem.IsMappingType(exp.Type)) { throw new NotSupportedException(exp.ToString()); } DbExpression dbExp = this.ResolveExpression(exp); MappingFieldExpression ret = new MappingFieldExpression(exp.Type, dbExp); return(ret); }
/// <summary> /// a => a.Id a => a.Name a => a.User /// </summary> /// <param name="exp"></param> /// <returns></returns> protected override IMappingObjectExpression VisitMemberAccess(MemberExpression exp) { //create MappingFieldExpression object if exp is map type if (MappingTypeSystem.IsMappingType(exp.Type)) { DbExpression dbExp = this.ResolveExpression(exp); MappingFieldExpression ret = new MappingFieldExpression(exp.Type, dbExp); return(ret); } //如 a.Order a.User 等形式 return(this.ResolveComplexMember(exp)); }
protected override DbExpression VisitParameter(ParameterExpression exp) { //TODO 只支持 MappingFieldExpression 类型,即类似 q.Select(a=> a.Id).Where(a=> a > 0) 这种情况,也就是 ParameterExpression.Type 为基本映射类型。 if (MappingTypeSystem.IsMappingType(exp.Type)) { IMappingObjectExpression moe = this.FindMoe(exp); MappingFieldExpression mfe = (MappingFieldExpression)moe; return(mfe.Expression); } else { throw new NotSupportedException(exp.ToString()); } }
protected override DbExpression VisitParameter(ParameterExpression exp) { //TODO 只支持 MappingFieldExpression 类型,即类似 q.Select(a=> a.Id).Where(a=> a > 0) 这种情况,也就是 ParameterExpression.Type 为基本映射类型。 if (Utils.IsMapType(exp.Type)) { int idx = this.FindParameterIndex(exp); IMappingObjectExpression moe = this._moeList[idx]; MappingFieldExpression mfe = (MappingFieldExpression)moe; return(mfe.Expression); } else { throw new NotSupportedException(exp.ToString()); } }
public virtual IQueryState Accept(FunctionExpression exp) { List <DbExpression> dbParameters = new List <DbExpression>(exp.Parameters.Count); foreach (Expression pExp in exp.Parameters) { var dbExp = GeneralExpressionVisitor.VisitPredicate((LambdaExpression)pExp, this.MoeList); dbParameters.Add(dbExp); } DbFunctionExpression dbFuncExp = new DbFunctionExpression(exp.ElementType, exp.Method, dbParameters); MappingFieldExpression mfe = new MappingFieldExpression(exp.ElementType, dbFuncExp); ResultElement result = new ResultElement(); result.MappingObjectExpression = mfe; result.FromTable = this._resultElement.FromTable; result.AppendCondition(this._resultElement.Condition); FunctionQueryState state = new FunctionQueryState(result); return(state); }
public virtual IQueryState Accept(FunctionExpression exp) { List<DbExpression> dbParameters = new List<DbExpression>(exp.Parameters.Count); foreach (Expression pExp in exp.Parameters) { var dbExp = GeneralExpressionVisitor.VisitPredicate((LambdaExpression)pExp, this.MoeList); dbParameters.Add(dbExp); } DbFunctionExpression dbFuncExp = new DbFunctionExpression(exp.ElementType, exp.Method, dbParameters); MappingFieldExpression mfe = new MappingFieldExpression(exp.ElementType, dbFuncExp); ResultElement result = new ResultElement(); result.MappingObjectExpression = mfe; result.FromTable = this._resultElement.FromTable; result.AppendCondition(this._resultElement.Condition); FunctionQueryState state = new FunctionQueryState(result); return state; }