如何从实体框架中获取来自两个表和内部的数据 [英] how get data from two table and inner join this in entity framework
本文介绍了如何从实体框架中获取来自两个表和内部的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
这是我的桌子类:
表格角色:
hi
this is my tables class:
the table roles:
public partial class Role
{
public Role()
{
this.Users = new HashSet<User>();
}
public int RoleID { get; set; }
public string RoleTitle { get; set; }
public string RoleInsystem { get; set; }
public virtual ICollection<User> Users { get; set; }
}
和表用户:
and the table users:
public partial class User
{
public int UserID { get; set; }
public int RoleID { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public virtual Role Role { get; set; }
}
i想得到这个fiels:User。*和Role.RoleTitle,其中User.RoleID = Role.RoleID
i want get this fiels:User.* and Role.RoleTitle where User.RoleID=Role.RoleID
推荐答案
尝试
使用实体框架加入查询 [ ^ ]
实体框架的左外连接扩展 [ ^ ]
这篇关于如何从实体框架中获取来自两个表和内部的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文