Example #1
0
        public CSpec <T1> And(string name)
        {
            CSpecProperty       sp = this.GetSpecProperty(name);
            ParameterExpression p  = Expression.Parameter(sp.Property.DeclaringType, "p");
            Expression          e  = Expression.MakeMemberAccess(p, sp.Property);
            var exp = Expression.Lambda <Func <T1, object> >(Expression.Convert(e, typeof(object)), p);

            this.ces.Add(exp);
            return(this);
        }
Example #2
0
        public CSpec <T1> And(string name, string orderType)
        {
            string methodName = "Desc";

            if (orderType.IsNullOrEmpty())
            {
                orderType = "Asc";
            }
            if ("ASC".Equals(orderType.ToUpper()))
            {
                methodName = "Asc";
            }
            CSpecProperty        sp = this.GetSpecProperty(name);
            ParameterExpression  p  = Expression.Parameter(sp.Property.DeclaringType, "p");
            Expression           e  = Expression.MakeMemberAccess(p, sp.Property);
            MethodCallExpression mc = Expression.Call(null, typeof(MethodExtend).GetMethod(methodName).MakeGenericMethod(sp.Property.PropertyType), e);
            var exp = Expression.Lambda(mc, p);

            this.ces.Add(exp);
            return(this);
        }