private DbUnitTypeExpression JoinTranslate(TranslationContext context, MethodCallExpression exp) { return(GropuAndJoinTranslate(context, exp, false)); }
private DbUnitTypeExpression UnitTypeTranslate(TranslationContext context, Expression exp) { switch (exp.NodeType) { case ExpressionType.Call: var callExpression = (MethodCallExpression)exp; var method = callExpression.Method; if (method.IsGenericMethod) { method = method.GetGenericMethodDefinition(); } if (UnitTypeMethods.TryGetValue(method, out UnitTypeTranslateMethodType action)) { return(action(context, callExpression)); } break; case ExpressionType.Constant: var constant = (ConstantExpression)exp; if (constant.Value is IDbSet dbset) { if (context.Context != dbset.Context) { throw new NotSupportedException(Res.NotSupportedContextIsNotMatch); } return(new DbDataSetExpression(constant.Type, dbset.Name)); } throw new TranslateException(exp, Res.ExceptionIsMustDbSetInstance); case ExpressionType.MemberAccess: var member = (MemberExpression)exp; if (member.Expression.NodeType == ExpressionType.MemberAccess) { var subexp = (MemberExpression)member.Expression; if (subexp.Expression.NodeType == ExpressionType.Constant) { var obj = Expression.Lambda(member).Compile().DynamicInvoke(); if (obj is IDbSet dbset2) { if (context.Context != dbset2.Context) { throw new NotSupportedException(Res.NotSupportedContextIsNotMatch); } return(new DbDataSetExpression(exp.Type, dbset2.Name)); } throw new TranslateException(exp, Res.ExceptionIsMustDbSetInstance); } if (ExpressionTranslate(context, member) is DbUnitTypeExpression unitExpression) { return(unitExpression); } } else { if (ExpressionTranslate(context, member) is DbUnitTypeExpression unitExpression) { return(unitExpression); } } break; } throw new TranslateException(exp, Res.NotSupportedParseUnitType); }