This question is locked. New answers and comments are not allowed.
I have the following simple query in SQL:
SELECT A.*
FROM Products AS A
WHERE EXISTS (SELECT B.Category_Id
FROM Categories AS B
WHERE B.Category_Type = 'Stationary'
AND B.Category_Id = A.Category_Id)
I successfully converted this to a Linq query as follows:
from a in Products
where (from b in Categories
where b.Category_Type == 'Stationary'
select b.Category_Id).Contains(a.Category_Id)
select a
However, the 'Stationary' value should be dynamic. Therefore, I downloaded the Dynamic.vb library for inclusion in my project (via Includes System.Linq.Dynamic) so I can then dynamically build this query. I started with:
Dim query = from a in Products
query.where(...
and this is where I got stuck! Can anyone assist in making this a dynamic query where I can populate the Category_Type based on user input?
SELECT A.*
FROM Products AS A
WHERE EXISTS (SELECT B.Category_Id
FROM Categories AS B
WHERE B.Category_Type = 'Stationary'
AND B.Category_Id = A.Category_Id)
I successfully converted this to a Linq query as follows:
from a in Products
where (from b in Categories
where b.Category_Type == 'Stationary'
select b.Category_Id).Contains(a.Category_Id)
select a
However, the 'Stationary' value should be dynamic. Therefore, I downloaded the Dynamic.vb library for inclusion in my project (via Includes System.Linq.Dynamic) so I can then dynamically build this query. I started with:
Dim query = from a in Products
query.where(...
and this is where I got stuck! Can anyone assist in making this a dynamic query where I can populate the Category_Type based on user input?