LINQ to SQL dynamic WHERE clause mulitple JOIN

J

Jay Douglas

Hello,

I've found some posts on creating dynamic WHERE clauses in LINQ to SQL using
predicate builders and extending lamda expressions. One issue with these
posts is all the examples only use a single customer table. I'm need a way
to dynamically create a where clause using multiple tables. None of the
tables I'm using have references in the LINQ designer so the JOIN operator
is required.

If I were to hard type out the query in linq it would look like: (Just an
example, I don't have the NWind schema in front of me)

var query = from c in db.Customers join o in db.Orders on c.CustomerId
equals o.CustomerId where c.LastName.Contains("Last") && o.OrderDate > new
DateTime("1/1/2001") select c;

I'm looking for some direction on dynamically setting the where predicates.

Any and all suggestions and GREATLY appreciated.

Many thanks in advance.

Jay Douglas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top