Esempio n. 1
0
        private Expression <Func <TRole, TValue> > GetRoleLambda <TValue>(Mapper.RoleColumnType columnType)
        {
            var param        = Expression.Parameter(RoleType, "p");
            var memberAccess = RoleHelper.GetMemberAccess(param, columnType);

            return(Expression.Lambda <Func <TRole, TValue> >(memberAccess, param));
        }
Esempio n. 2
0
        private Expression <Func <TRole, bool> > GetRoleLambda(Mapper.RoleColumnType columnType, object value, bool appFilter)
        {
            var param        = Expression.Parameter(RoleType, "p");
            var memberAccess = RoleHelper.GetMemberAccess(param, columnType);
            var content      = Expression.Constant(value);
            var equal        = Expression.Equal(memberAccess, content);

            //if (appFilter && Provider.SupportApplication) {
            //    var appMember = RoleHelper.GetMemberAccess(param, Mapper.RoleColumnType.Application);
            //    var appName = Expression.Property(appMember, "Name");
            //    var appCheck = Expression.Equal(appName, Expression.Constant(Provider.ApplicationName));

            //    return Expression.Lambda<Func<TRole, bool>>(Expression.And(equal, appCheck), param);
            //}

            return(Expression.Lambda <Func <TRole, bool> >(equal, param));
        }
Esempio n. 3
0
        private Expression <Func <TRole, bool> > GetRoleContainsLambda(Mapper.RoleColumnType columnType, IEnumerable <TRoleKey> value, bool appFilter)
        {
            var param        = Expression.Parameter(RoleType, "p");
            var memberAccess = RoleHelper.GetMemberAccess(param, columnType);

            if (containsMethod_TRoleKey == null)
            {
                var type = typeof(System.Linq.Enumerable);
                containsMethod_TRoleKey = type.GetMethods().First(f => f.Name.Equals("Contains")).MakeGenericMethod(typeof(TRoleKey));
            }
            var call = Expression.Call(null, containsMethod_TRoleKey, Expression.Constant(value), memberAccess);

            if (appFilter && Provider.SupportApplication)
            {
                var appMember = RoleHelper.GetMemberAccess(param, Mapper.RoleColumnType.Application);
                var appName   = Expression.Property(appMember, "Name");
                var appCheck  = Expression.Equal(appName, Expression.Constant(Provider.ApplicationName));

                return(Expression.Lambda <Func <TRole, bool> >(Expression.And(call, appCheck), param));
            }

            return(Expression.Lambda <Func <TRole, bool> >(call, param));
        }
Esempio n. 4
0
 private Expression <Func <TRole, bool> > GetRoleLambda(Mapper.RoleColumnType columnType, object value)
 {
     return(GetRoleLambda(columnType, value, false));
 }