Beispiel #1
0
        private void ResolveDateDiff(ExpressionParameter parameter, bool?isLeft, MemberExpression expression)
        {
            var binaryExp = expression.Expression as BinaryExpression;
            var beginExp  = binaryExp.Right;
            var endExp    = binaryExp.Left;

            var dateType = DateType.Day;
            var begin    = GetNewExpressionValue(beginExp);
            var end      = GetNewExpressionValue(endExp);

            foreach (var item in UtilMethods.EnumToDictionary <DateType>())
            {
                if (expression.Member.Name.ToLower().Contains(item.Key.ToLower()))
                {
                    dateType = item.Value;
                    break;
                }
            }
            var result = this.Context.DbMehtods.DateDiff(new MethodCallExpressionModel()
            {
                Args = new List <MethodCallExpressionArgs>()
                {
                    new MethodCallExpressionArgs()
                    {
                        MemberName  = dateType,
                        MemberValue = dateType
                    },
                    new MethodCallExpressionArgs()
                    {
                        MemberName  = begin,
                        MemberValue = begin
                    },
                    new MethodCallExpressionArgs()
                    {
                        MemberName  = end,
                        MemberValue = end
                    }
                }
            });;

            base.AppendMember(parameter, isLeft, result);
        }