I’m working with a client who wants to mix LINQ to SQL with their in-house DAL. Ultimately they want to be able to query their layer using typical LINQ syntax. The point where this gets tricky is that they build their queries dynamically. So ultimately what I want is to be able to take a LINQ query, pull it apart and be able to inspect the pieces to pull the correct objects out, but I don’t really want to build a piece to translate the ‘where’ expression into SQL. Is this something I can just generate using Microsoft code? Or is there an easier way to do this?
Share
(you mean just LINQ, not really LINQ-to-SQL)
Sure, you can do it – but it is massive amounts of work. Here’s how; I recommend “don’t”. You could also look at the source code for DbLinq – see how they do it.
If you just want
Where, it is a bit easier – but as soon as you start getting joins, groupings, etc – it will be very hard to do.Here’s just
Wheresupport on a custom LINQ implemention (not a fully queryable provider, but enough to get LINQ withWhereworking):