I need to generate the dynamic cross join linq query for the below sql Query
SQL - Select Query for complex dynamic rows
I need to create number of subquery joins(Listing Table) based on ExtraField Count .
If ExtraField Count = 4 , create 4 cross joins.
If ExtraField Count = 2 , create 2 cross joins only.
SELECT t1.ListingID
FROM Listing AS t1
INNER JOIN Listing AS t2
ON t2.ListingID = t1.ListingID
INNER JOIN Listing AS t3
ON t3.ListingID = t1.ListingID
INNER JOIN Listing AS t4
ON t4.ListingID = t1.ListingID
WHERE (t1.ExtraFieldID = 1 AND t1.Value = 1)
AND (t2.ExtraFieldID = 2 AND t2.Value = 7)
AND (t3.ExtraFieldID = 3 AND t3.Value = '')
AND (t4.ExtraFieldID = 4 AND t4.Value = 1999)