我有那两个模型
public class BranchEmployees
{
public int ID { get; set; }
[Required, Column(Order = 0), Key]
public string ApplicationUserID { get; set; }
[Required, Column(Order = 1), Key]
public int BranchID { get; set; }
public virtual ICollection<ApplicationUser> ApplicationUser { get; set; }
public virtual ICollection<Branch> Branch { get; set; }
}
public class Branch
{
public int ID { get; set; }
public string BranchName { get; set; }
[Required]
public string ApplicationUserID { get; set; }
public ApplicationUser User { get; set; }
public virtual ICollection<BranchEmployees> BranchEmployees { get; set; }
}
public class ApplicationUser
{
//rest of the code
}
更新我已设置了所有内容,但我想要的是使我获得ID在分支employees表中的Employees的查询,我首先在MVC 5中使用实体框架代码,我该怎么做?
假设您的ApplicationUser
班级具有名为的导航属性BranchEmployees
,这是使我获得ID在分支employees表中的Employees的查询
List<ApplicationUsers> employeeNames =
dbContext
.ApplicationUsers
.Where(au => au.BranchEmployees
.Count() > 0).ToList();
另外,您可以提供包括ApplicationUser在内的整个模型吗?我也想知道为什么您不喜欢BranchEmployees从ApplicationUser继承。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句