Home > Net >  Using the.net framework EF6 cascade query
Using the.net framework EF6 cascade query

Time:04-14

 
Public class News
{
Public int ID {get; set; }
Public string Title {get; set; }
Public List RoleList {get; set; }
}
Public class roles
{
Public int ID {get; set; }
Public string Title {get; set; }
Public List The UserList {get; set; }
Public List NewsList {get; set; }
}
Public class User
{
Public int ID {get; set; }
Public string Name {get; set; }
Public List RoleList {get; set; }
}


without using the core ThenInclude
Is currently the only access to the inside of the news Role but want to get the User won't find it

 
Using (DataContext DataContext=new DataContext ()) {
List News=dataContext. News. AsNbTracking (). The Include (d=& gt; D.R oleList). ToList ()
}

I also need the inside of the Role the User set could you tell me how to write should need

CodePudding user response:

For example
Mainly is to set up ForeignKey
 public partial class WD_MyProject 
{
[Key]
Public int id {get; set; }
Public int uid {get; set; }

[ForeignKey (" uid ")]
Public virtual WD_Employee WD_Employee {get; set; }

}
  •  Tags:  
  • C#
  • Related