c# - How to query database if it consists of many to many mapping? -
this question has answer here:
- many many query in entity framework 4 3 answers
i using entity framework 6 , project consists of fluent api mappings entites. used entity framework generator generate classes , mappings.
i have 3 tables in database
-user -roles -userroles
userroles
consists of both userid
, rolesid
.
entity framework generator doesnot generate userrole mapping , entity class. puts mapping in role class
i name
of role based on userid
. how query it.
thanks in advance.
var userid = "bad5ea54-f32b-4450-ae50-883acdfda41d"; var query = user in context.aspnetusers user.id == userid userrole in aspnetuserroles userrole.user == user role in aspnetroles role == userrole.role select role.name;
Comments
Post a Comment