Пример #1
0
        public static Expression <Func <T, bool> > And <T>(string[] keys, T t)
        {
            if (keys == null)
            {
                return(null);
            }
            var expression = EfUtils.True <T>();

            for (int i = 0; i < keys.Length; i++)
            {
                var text = keys[i];
                var expr = t.GetType().GetProperty(text);
                var val  = expr.GetValue(t, null).ToString();
                var type = expr.ToString();
                if (text.ToLower().Equals("datetime") || text.ToLower().Equals("clientdatetime"))
                {
                    expression = expression.And(EfUtils.AndIndexOf <T>(type, text, val));
                }
                else
                {
                    expression = expression.And(EfUtils.And <T>(type, text, val));
                }
            }
            return(expression);
        }
Пример #2
0
        public static Expression <Func <T, bool> > AndOr <T>(string[] keys, string orKey, T t)
        {
            if (keys == null)
            {
                return(null);
            }
            var expression = EfUtils.And <T>(keys, t);

            if (!string.IsNullOrEmpty(orKey))
            {
                Expression <Func <T, bool> > exp_right = EfUtils.And <T>(new string[]
                {
                    orKey
                }, t);
                expression = expression.Or(exp_right);
            }
            return(expression);
        }