Last post Apr 24, 2018 04:50 AM by DA924
Apr 19, 2018 09:22 PM|praveen_katta|LINK
I have 2 queries which have same table joins but different where conditions. I need to compare the result of these 2 queries. Instead of saying .ToList() on each query and getting the result into memory and comparing can I join these 2 IQuerables and then
perform the comparison? My goal is to hit DB only once. Please help!!
Apr 20, 2018 02:37 AM|Brando ZWZ|LINK
According to your description, I suggest you could write a sql query to select the result which you want instead of using linq to get the result.
I suggest you could refer to below query example:
Select * FROM
QUERY A GOES HERE
) AS A
QUERY B GOES HERE
) AS B
ON A.Col1=B.Col1 AND A.Col2=B.Col2 ....
Apr 24, 2018 04:50 AM|DA924|LINK
If you close the connection after you do the ToList(), then you have disconnected objects in the LIst<T>. As the objects are iterated over with a loop within the List<T> as an example, the objects are not populated again from the database, because the objects