As Daniel notes, this is far from easy. The solution outline should allow GetProduct to take an argument of type Expression<Func<Product, bool>> . Then you need to parse this expression by creating the correct SQL for the known functions and also deciding how to handle the unknown functions. There are two options for this:
- Throw an error (as linq-to-sql does).
- Skip it in the translation, and then apply it to the returned result. The effective impact of this can, of course, be enormous if a lot of data is restored only for filtering.
It would be fun to do this exercise, but I can hardly justify it in the real world when there are already linq2sql, linq2entities and linq2NHibernate that do the job.
source share