[英]Linq for mapping table
I dont know how to write linq for the given scenario. 我不知道如何为给定场景编写linq。 Any help please?
有什么帮助吗?
I have three tables 我有三张桌子
I need a query to get the employeeName from employeetable and rolename from role table. 我需要一个查询以从employeetable获取employeeName,从角色表获取rolename。
Any help please? 有什么帮助吗?
I am generating the mapping table in using entity framework like below, i am not getting the third table name, now to get the name of the table for writing the linq 我正在使用如下所示的实体框架生成映射表,我没有得到第三个表名,现在要获取用于编写linq的表的名称
modelBuilder.Entity<Employee>()
.HasMany(role => role.Roles)
.WithMany(emp => emp.employee)
.Map(role => role.MapLeftKey("RoleId").MapRightKey("EmployeeId").ToTable("EmployeeRoleMapping"));
var query = from emp in db.Employee
join empRole in db.EmpRoleMapping
on emp.empid equals empRole.empid
join r in db.Role
on empRole.roleid equals r.roleid
select new { employeeName = emp.name, rolename = r.rolename };
我猜这:
var result = employee.Select(e => e.name, e.Role.rolename);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.