@@ -95,68 +95,68 @@ public async Task<IEnumerable<Guid>> TenantIdsAsync(Query.Identity.Specification
9595 } ) ;
9696 }
9797
98- private IQueryable < Models . Identity > GetQueryable ( Query . Identity . Specification identitySpecification )
98+ private IQueryable < Models . Identity > GetQueryable ( Query . Identity . Specification specification )
9999 {
100100 var queryable = _accessDbContext . Identities
101101 . AsNoTracking ( ) ;
102102
103- queryable = identitySpecification . ShouldIncludeTenants
103+ queryable = specification . ShouldIncludeTenants
104104 ? queryable . Include ( item => item . IdentityTenants ) . ThenInclude ( item => item . Tenant )
105105 : queryable ;
106106
107- queryable = identitySpecification is { ShouldIncludeRoles : true , ShouldIncludePermissions : false }
108- ? queryable . Include ( item => item . IdentityRoles )
107+ queryable = specification is { ShouldIncludeRoles : true , ShouldIncludePermissions : false }
108+ ? queryable . Include ( item => item . IdentityRoles . Where ( role => role . TenantId == specification . TenantId ) )
109109 . ThenInclude ( item => item . Role )
110110 . ThenInclude ( item => item . Tenant )
111111 : queryable ;
112112
113- queryable = identitySpecification . ShouldIncludePermissions
113+ queryable = specification . ShouldIncludePermissions
114114 ? queryable . Include ( item => item . IdentityRoles ) . ThenInclude ( item => item . Role ) . ThenInclude ( item => item . RolePermissions ) . ThenInclude ( item => item . Permission )
115115 : queryable ;
116116
117- if ( ! string . IsNullOrEmpty ( identitySpecification . NameMatch ) )
117+ if ( ! string . IsNullOrEmpty ( specification . NameMatch ) )
118118 {
119- queryable = queryable . Where ( e => e . Name . Contains ( identitySpecification . NameMatch ) || e . Description . Contains ( identitySpecification . NameMatch ) ) ;
119+ queryable = queryable . Where ( e => e . Name . Contains ( specification . NameMatch ) || e . Description . Contains ( specification . NameMatch ) ) ;
120120 }
121121
122- if ( ! string . IsNullOrEmpty ( identitySpecification . Name ) )
122+ if ( ! string . IsNullOrEmpty ( specification . Name ) )
123123 {
124- queryable = queryable . Where ( e => e . Name == identitySpecification . Name || e . Description == identitySpecification . Name ) ;
124+ queryable = queryable . Where ( e => e . Name == specification . Name || e . Description == specification . Name ) ;
125125 }
126126
127- if ( identitySpecification . TenantId != null )
127+ if ( specification . TenantId != null )
128128 {
129- queryable = queryable . Where ( e => e . IdentityTenants . Any ( it => it . TenantId == identitySpecification . TenantId ) ) ;
129+ queryable = queryable . Where ( e => e . IdentityTenants . Any ( it => it . TenantId == specification . TenantId ) ) ;
130130 }
131131
132- if ( ! string . IsNullOrEmpty ( identitySpecification . RoleName ) )
132+ if ( ! string . IsNullOrEmpty ( specification . RoleName ) )
133133 {
134- queryable = queryable . Where ( e => e . IdentityRoles . Any ( ir => ir . Role . Name == identitySpecification . RoleName ) ) ;
134+ queryable = queryable . Where ( e => e . IdentityRoles . Any ( ir => ir . Role . Name == specification . RoleName ) ) ;
135135 }
136136
137- if ( identitySpecification . RoleId != null )
137+ if ( specification . RoleId != null )
138138 {
139- queryable = queryable . Where ( e => e . IdentityRoles . Any ( ir => ir . RoleId == identitySpecification . RoleId ) ) ;
139+ queryable = queryable . Where ( e => e . IdentityRoles . Any ( ir => ir . RoleId == specification . RoleId ) ) ;
140140 }
141141
142- if ( identitySpecification . PermissionId != null )
142+ if ( specification . PermissionId != null )
143143 {
144- queryable = queryable . Where ( e => e . IdentityRoles . Any ( ir => ir . Role . RolePermissions . Any ( rp => rp . PermissionId == identitySpecification . PermissionId ) ) ) ;
144+ queryable = queryable . Where ( e => e . IdentityRoles . Any ( ir => ir . Role . RolePermissions . Any ( rp => rp . PermissionId == specification . PermissionId ) ) ) ;
145145 }
146146
147- if ( identitySpecification . HasIds )
147+ if ( specification . HasIds )
148148 {
149- queryable = queryable . Where ( e => identitySpecification . Ids . Contains ( e . Id ) ) ;
149+ queryable = queryable . Where ( e => specification . Ids . Contains ( e . Id ) ) ;
150150 }
151151
152- if ( identitySpecification . HasExcludedIds )
152+ if ( specification . HasExcludedIds )
153153 {
154- queryable = queryable . Where ( e => ! identitySpecification . ExcludedIds . Contains ( e . Id ) ) ;
154+ queryable = queryable . Where ( e => ! specification . ExcludedIds . Contains ( e . Id ) ) ;
155155 }
156156
157- if ( identitySpecification . MaximumRows > 0 )
157+ if ( specification . MaximumRows > 0 )
158158 {
159- queryable = queryable . Take ( identitySpecification . MaximumRows ) ;
159+ queryable = queryable . Take ( specification . MaximumRows ) ;
160160 }
161161
162162 return queryable . AsSplitQuery ( ) ;
0 commit comments