Linq Nested Queries

What is a valid Linq statement for

from a in Active_SLA 
where a.APP_ID == (from f in FORM_PAGES where f.PAGE_ADDRESS == @Address select f.APP_ID)
    && a.PERSON_ID == (from p in PERSON_DEVICES where p.DEVICE_NUMBER == @number select p.PERSON_ID) 
select a.PRIORITY
+3
source share
1 answer

Instead of nested queries, you should use join operators to join tables based on matching columns.

In your example, the correct Linq query would look something like this:

from a in Active_SLA
join f in FORM_PAGES on a.APP_ID equals f.APP_ID
join p in PERSON_DEVICES on a.PERSON_ID equals p.PERSON_ID
where (f.PAGE_ADDRESS == @Address) && (p.DEVICE_NUMBER == @number)
select a.PRIORITY;

Hope this helps!

+2
source

Source: https://habr.com/ru/post/1708227/


All Articles