c# - Get users by user role and subsidiary ID -
in asp.net identity have following tables
aspnetusers
aspnetroles
aspnetuserroles
additionally added following column aspnetusers
table
subsidiary_id
now want load list
following filters
- rolename == "approver"
- subsidiary_id == "04"
so purpose i'm trying write query below
list<aspnetuser> approverprofiles = db.aspnetusers.where(w => w.subsidary_id == "04").where(w => w.name == "approver").tolist();
but i'm getting error
'aspnetuser' not contain definition 'name' , no extension method 'name'
you searching rolename in aspnetusers table, not exist. if want users have subsidiary_id == "04" , in role rolename == "approver" must query this:
list<aspnetuser> approverprofiles = db.aspnetusers .where(w => w.subsidary_id == "04" && w.roles.any(r => r.name == "approver")) .tolist();
Comments
Post a Comment