private DbUnitTypeExpression OrderByDescendingTranslate(TranslationContext context, MethodCallExpression exp) { var source = UnitTypeTranslate(context, exp.Arguments[0]); if (source.Orders.Count > 0) { source.Orders.Clear(); } return(context.Lambda <DbUnitTypeExpression>(delegate(Expression e1) { source.Orders.Add(new DbOrderExpression(ExpressionTranslate(context, e1), EOrderKind.Descending)); return source; }, exp.Arguments[1], source.Item)); }
private DbUnitTypeExpression GropuAndJoinTranslate(TranslationContext context, MethodCallExpression exp, bool isgroup) { var source = UnitTypeTranslate(context, exp.Arguments[0]); var target = UnitTypeTranslate(context, exp.Arguments[1]); var left = context.Lambda <DbExpression>(delegate(Expression body) { return(ExpressionTranslate(context, body)); }, exp.Arguments[2], source.Item); var right = context.Lambda <DbExpression>(delegate(Expression body) { return(ExpressionTranslate(context, body)); }, exp.Arguments[3], target.Item); var rightitem = isgroup ? (DbExpression) new DbGroupSetExpression(target) : target.Item; var result = context.Lambda <DbUnitItemTypeExpression>(delegate(Expression body) { return(UnitItemTypeTranslate(context, body) as DbUnitItemTypeExpression); }, exp.Arguments[4], source.Item, rightitem); if (result.ExpressionType == EExpressionType.DataItem || result.ExpressionType == EExpressionType.GroupItem) { result = new DbUnitItemContentExpression(result); } if (isgroup) { var value = new DbGroupJoinExpression(source, target, left, right, result); ((DbGroupSetExpression)rightitem).Parent = value; return(value); } else { return(new DbInnerJoinExpression(source, target, left, right, result)); } }
private DbExpression JudgeFunctionInlineTranslate(TranslationContext context, MethodCallExpression call, MethodInfo method) { var source = ExpressionConvertUnitType(ExpressionTranslate(context, call.Arguments[0])); if (source == null) { throw new TranslateException(call.Arguments[0], Res.ExceptionIsNotUnitType); } if (call.Arguments.Count == 2) { DbExpression content = context.Lambda <DbExpression>(delegate(Expression body) { return(ExpressionTranslate(context, body)); }, call.Arguments[1], source.Item); return(new DbJudgeFunctionExpression(source, method, content)); } return(new DbJudgeFunctionExpression(source, method)); }
private DbUnitTypeExpression SelectTranslate(TranslationContext context, MethodCallExpression exp) { var source = UnitTypeTranslate(context, exp.Arguments[0]); return(context.Lambda <DbUnitTypeExpression>(delegate(Expression body) { var itemType = UnitItemTypeTranslate(context, body) as DbUnitItemTypeExpression; switch (itemType.ExpressionType) { case EExpressionType.DataItem: case EExpressionType.GroupItem: itemType = new DbUnitItemContentExpression(itemType); break; case EExpressionType.Select: //如果出现重复SELECT调用则自动合并 return ((DbSelectExpression)source).ReplaceItem(itemType); } return new DbSelectExpression(source, itemType); }, exp.Arguments[1], source.Item)); }