Beispiel #1
0
        private Expression <Func <TUserRole, TValue> > GetUserRoleLambda <TValue>(Mapper.UserRoleColumnType columnType)
        {
            var param        = Expression.Parameter(UserRoleType, "p");
            var memberAccess = UserRoleHelper.GetMemberAccess(param, columnType);

            return(Expression.Lambda <Func <TUserRole, TValue> >(memberAccess, param));
        }
Beispiel #2
0
        private Expression <Func <TUserRole, bool> > GetUserRoleLambda(Mapper.UserRoleColumnType columnType, object value)
        {
            var param        = Expression.Parameter(UserRoleType, "p");
            var memberAccess = UserRoleHelper.GetMemberAccess(param, columnType);
            var content      = Expression.Constant(value);
            var equal        = Expression.Equal(memberAccess, content);

            return(Expression.Lambda <Func <TUserRole, bool> >(equal, param));
        }
Beispiel #3
0
        private Expression <Func <TUserRole, bool> > GetContainsJoinLambda(IEnumerable <TUserRole> Joins, bool Not)
        {
            var param = Expression.Parameter(UserRoleType, "p");

            if (Joins.Count() < 1)
            {
                return(Expression.Lambda <Func <TUserRole, bool> >(Expression.Constant(true), param));
            }

            var memberAccess1 = UserRoleHelper.GetMemberAccess(param, Mapper.UserRoleColumnType.RoleID);
            var memberAccess2 = UserRoleHelper.GetMemberAccess(param, Mapper.UserRoleColumnType.UserID);

            var allEquals = Joins.Select(s => Expression.And(Expression.Equal(memberAccess1, Expression.Constant(Provider.UserRoleMapper.RoleID(s))),
                                                             Expression.Equal(memberAccess2, Expression.Constant(Provider.UserRoleMapper.UserID(s)))));
            Expression all = allEquals.Aggregate((o, n) => Expression.Or(o, n));

            if (Not)
            {
                all = Expression.Not(all);
            }

            return(Expression.Lambda <Func <TUserRole, bool> >(all, param));
        }