public async Task <IList <ApplicationUser> > GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (var adapter = new DataAccessAdapter())
            {
                var qf = new QueryFactory();
                var q  = qf.AspNetUser.From(QueryTarget
                                            .InnerJoin(AspNetUserClaimEntity.Relations.AspNetUserEntityUsingUserId))
                         .Where(AspNetUserClaimFields.ClaimType.Equal(claim.Type)
                                .And(AspNetUserClaimFields.ClaimValue.Equal(claim.Value)))
                         .Select(ProjectionLambdaCreator.Create <ApplicationUser, AspNetUserFields>());

                var users = await adapter.FetchQueryAsync(q, cancellationToken);

                return(users);
            }
        }
        public async Task <IList <ApplicationUser> > GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            using (var adapter = new DataAccessAdapter())
            {
                var qf = new QueryFactory();
                var q  = qf.AspNetUser.From(QueryTarget
                                            .InnerJoin(AspNetRoleEntity.Relations.AspNetUserRoleEntityUsingRoleId)
                                            .InnerJoin(AspNetUserRoleEntity.Relations.AspNetUserEntityUsingUserId))
                         .Where(AspNetRoleFields.Name.Equal(roleName))
                         .AndWhere(AspNetUserRoleFields.RoleId.Equal(AspNetRoleFields.Id))
                         .Select(ProjectionLambdaCreator.Create <ApplicationUser, AspNetUserFields>());

                var users = await adapter.FetchQueryAsync(q, cancellationToken);

                return(users);
            }
        }
Ejemplo n.º 3
0
 /// <summary>Gets the projection to project the resultset of stored procedure HR.GetEmployeeClassifications to the typed view GetEmployeeClassificationsResult</summary>
 /// <returns>Projection in the form of a Dynamic Query which projects to <see cref="LLBLGenPro.OrmCookbook.TypedViewClasses.GetEmployeeClassificationsResultRow"/> instances </returns>
 public DynamicQuery <LLBLGenPro.OrmCookbook.TypedViewClasses.GetEmployeeClassificationsResultRow> GetGetEmployeeClassificationsResultTypedViewProjection()
 {
     return(this.Create().Select(ProjectionLambdaCreator.Create <LLBLGenPro.OrmCookbook.TypedViewClasses.GetEmployeeClassificationsResultRow>(ModelInfoProviderSingleton.GetInstance().GetTypedViewFields("GetEmployeeClassificationsResultTypedView"), true)));
 }
 /// <summary>Gets the projection to project the resultset of stored procedure dbo.VenueDistance to the typed view VenueDistanceResult</summary>
 /// <returns>Projection in the form of a Dynamic Query which projects to <see cref="TournamentManager.DAL.TypedViewClasses.VenueDistanceResultRow"/> instances </returns>
 public DynamicQuery <TournamentManager.DAL.TypedViewClasses.VenueDistanceResultRow> GetVenueDistanceResultTypedViewProjection()
 {
     return(this.Create().Select(ProjectionLambdaCreator.Create <TournamentManager.DAL.TypedViewClasses.VenueDistanceResultRow>(ModelInfoProviderSingleton.GetInstance().GetTypedViewFields("VenueDistanceResultTypedView"), true)));
 }