How to convert sql query to entity framework core

entity-framework entity-framework-6 entity-framework-core

Question

I want to convert sql query to entity framework core. SQL query is

select * from Departments where id in(select DepartmentId from SubDepartments where id in(select SubDeptId from Tests where id in(select TestId from PatientTests where PatientId=3)))
1
0
4/16/2020 10:20:04 AM

Popular Answer

Assuming navigation properties are implemented, and without having any example code, this is a best estimate of how to implement it.

context.Departments.Where(x => x.SubDepartment.Test.PatientTest.PatientId == 3);
0
4/16/2020 4:21:06 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow