Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Complicated Join in Entity Framework

I have 3 tables in a database (picture below). I am trying to join the tables so I can get all the related information from all the tables. I am starting at DAT_Demo and I have been able to get all the records from DAT_Demo and ARC_Records, but I cannot figure out how to also pull in all the DAT_OrderDoctors records associated with ARC_Records. I have the following code that pulls the records I want but DAT_OrderDoctors is not available. How can i do this?

Code so far:

IQueryable<DAT_Demo> query = _localContext.DAT_Demo
    .Include("ARC_Records")
    .Include("ARC_Immuno")
    .OrderBy(d => d.LastName)
    .Where(d => SqlFunctions.PatIndex(txtSearch.Text + "%", d.FirstName + " " + d.LastName) > 0)
    .Take(100);

demo = query.ToList();

enter image description here

like image 257
Steve S Avatar asked Nov 30 '25 09:11

Steve S


1 Answers

I think you are after a second level include

.Include("ARC_Records.DAT_OrderDoctor")

or

.Include(d=>d.ARC_Records.Secect(a=>a.DAT_OrderDoctor))
like image 106
Not loved Avatar answered Dec 02 '25 04:12

Not loved