List of users that not yet in any role, (MVC4 with SimpleMembership and entity framework 5)

vicky

I am using mvc 4 with entity framework. I need a list of all users that have not yet been assigned any role. I cannot find any predefined function in Role.

enter image description here

Output will be.

enter image description here

My current code is as following.

var users = db.UserProfileEFMs
    .ToList()
    .Where(o => !Roles.GetRolesForUser(o.UserName).ToList<string>().Any())
    .ToList();

but it is not working properly or is too slow. Is there any another way to get that kind of list.

I am looking for an Extentions method for Roles like.

public static class Extentions
{
public static List<string>/*UserName*/ UsersNotInAnyRole(this Roles /*System.Web.Security*/ roles)
{
    /*----code----*/
}
}

currently i am using the following code

var users = db.Database.SqlQuery<UserProfile>("select * from dbo.UserProfile where UserId not in(select UserId from dbo.webpages_UsersInRoles)").ToList();
vicky

I don't get better solution. I think following is the best one.

var users = db.Database.SqlQuery<UserProfile>("select * from dbo.UserProfile where UserId not in(select UserId from dbo.webpages_UsersInRoles)").ToList();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Log4net with Entity Framework 5 and MVC4

From Dev

MVC 5 Entity Framework 6 Getting all user in a role

From Dev

How to list users with role names in ASP.NET MVC 5

From Dev

PieChart in mvc4 from Entity Framework

From Dev

Dropdownlist and MVC4 Entity Framework

From Dev

Send a list of users by email in MVC4

From Dev

Asp MVC Entity Framework Check if Permission Is In Role

From Dev

How can i create a Partial View for MVC4 or MVC 5 using Entity Framework (.edmx Model) with Razor Views?

From Dev

SimpleMembership MVC4 (existing database)

From Dev

How to mock method with ViewModel in MVC4 with Entity Framework 4.0

From Dev

Will Orchard CMS support MVC4 with Entity Framework

From Dev

MVC4 Entity Framework Controller Database Issue

From Dev

MVC4 app - how to remove Entity Framework and implement SimpleMembershipProvider?

From Dev

How to mock method with ViewModel in MVC4 with Entity Framework 4.0

From Dev

MVC4 Entity Framework 6 Model State Validation Issues

From Dev

RESTRICT ACCESS TO Controller ACTIONS For a list of users in MVC4

From Dev

List of Users with their single Role in MVC 6 left joined

From Dev

Entity Framework Add User to Role

From Dev

Entity Framework - good SQL, yet slow

From Dev

Comparing performance of generated queries for Any() vs Count() in Entity Framework 5

From Dev

Issue with MVC5 entity framework

From Dev

jQuery Datatable with MVC 5 and Entity Framework

From Dev

Add Entity Framework 7 to an MVC 5 project

From Dev

Concurrency in ASP .NET MVC 5 with Entity Framework

From Dev

Entity Framework 6.0 in MVC 5 project not working

From Dev

Struggling using MVC 5 and Entity Framework 6

From Dev

Entity framework error in MVC5 project

From Dev

Add Entity Framework 7 to an MVC 5 project

From Dev

Create default roles and users using SimpleMembership MVC 4 - Code first approach

Related Related

  1. 1

    Log4net with Entity Framework 5 and MVC4

  2. 2

    MVC 5 Entity Framework 6 Getting all user in a role

  3. 3

    How to list users with role names in ASP.NET MVC 5

  4. 4

    PieChart in mvc4 from Entity Framework

  5. 5

    Dropdownlist and MVC4 Entity Framework

  6. 6

    Send a list of users by email in MVC4

  7. 7

    Asp MVC Entity Framework Check if Permission Is In Role

  8. 8

    How can i create a Partial View for MVC4 or MVC 5 using Entity Framework (.edmx Model) with Razor Views?

  9. 9

    SimpleMembership MVC4 (existing database)

  10. 10

    How to mock method with ViewModel in MVC4 with Entity Framework 4.0

  11. 11

    Will Orchard CMS support MVC4 with Entity Framework

  12. 12

    MVC4 Entity Framework Controller Database Issue

  13. 13

    MVC4 app - how to remove Entity Framework and implement SimpleMembershipProvider?

  14. 14

    How to mock method with ViewModel in MVC4 with Entity Framework 4.0

  15. 15

    MVC4 Entity Framework 6 Model State Validation Issues

  16. 16

    RESTRICT ACCESS TO Controller ACTIONS For a list of users in MVC4

  17. 17

    List of Users with their single Role in MVC 6 left joined

  18. 18

    Entity Framework Add User to Role

  19. 19

    Entity Framework - good SQL, yet slow

  20. 20

    Comparing performance of generated queries for Any() vs Count() in Entity Framework 5

  21. 21

    Issue with MVC5 entity framework

  22. 22

    jQuery Datatable with MVC 5 and Entity Framework

  23. 23

    Add Entity Framework 7 to an MVC 5 project

  24. 24

    Concurrency in ASP .NET MVC 5 with Entity Framework

  25. 25

    Entity Framework 6.0 in MVC 5 project not working

  26. 26

    Struggling using MVC 5 and Entity Framework 6

  27. 27

    Entity framework error in MVC5 project

  28. 28

    Add Entity Framework 7 to an MVC 5 project

  29. 29

    Create default roles and users using SimpleMembership MVC 4 - Code first approach

HotTag

Archive