Ejemplo n.º 1
0
        public QueryObject <Role> QueryRoles(RoleRequest roleRequest)
        {
            var sql =
                @"select t.* from roles t where 
(@UserId is null or t.RoleId in (Select ur.Role_RoleId from UserRoles ur where ur.User_UserId = @UserId))
and (@Name is null or @Name = Name)
and (@NameWith is null or Name like @NameWith)
and (@DisplayNameWith is null or DisplayName like @DisplayNameWith)
and (@State is null or State = @State)
";

            return(new QueryObject <Role>(_databaseInstance, sql, roleRequest));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取角色列表
        /// </summary>
        /// <param name="roleRequest"></param>
        /// <returns></returns>
        public DataTables <Role> GetRoles(RoleRequest roleRequest)
        {
            SqlParameter[] param =
            {
                new SqlParameter("@Name",            roleRequest.Name),
                new SqlParameter("@pageIndex",       roleRequest.PageIndex),
                new SqlParameter("@pageSize",        roleRequest.PageSize),
                new SqlParameter("@DisplayNameWith", roleRequest.DisplayNameWith),
                new SqlParameter("@NameWith",        roleRequest.NameWith),
                new SqlParameter("@UserId",          roleRequest.UserId),
                new SqlParameter("@State",           roleRequest.State)
            };
            StoreProcedure sp = new StoreProcedure("P_getRoles", param);

            return(_databaseInstance.GetTables <Role>(sp));
        }