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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -