Are LINQ queries over different LINQ providers possible?

I am currently thinking of a repository pattern for my data objects where multiple instances IQueryable<>

can be registered as data sources, but it doesn't seem to be that easy to get started.

Running a simple LINQ query with LINQ for Objects and LINQ To Objects doesn't work. Do you think this is even possible? Maybe the only solution is to record the specified provider?

In my repository, I called .Union<>()

on all instances of the IQueryable and then finally used LINQ to query the resulting single IQueryable

. As a result, one IQueryable

was completely ignored.

0


source to share


2 answers


Well, I use LINQ queries on lists, collections, a whole bunch of stuff. I am using very similar queries on SQL tables. I didn't have any problems. I have heard of people having problems with LINQ queries in LINQ for objects, but I think they are usually treated as LINQ errors, not design differences in the way LINQ for objects, LINQ to XML, and LINQ to SQL. I had some problems with LINQ a few days before I installed VS 2008 SP1, but they have been resolved since then.



As long as you take into account what the query returns, it should work fine.

0


source


I have absolutely no documentation to support this, but I do recall some discussion in the pre-release days about optimizations that were built into Linq to SQL that would try to eliminate multiple calls to the database when doing Linq operations on SQL IQueryable <> objects and Linq objects to the IQueryable <> object. This, combined with the general architecture of the IQueryable interfaces, makes me think there should be no problem with the various vendors. However, it seems possible that interoperability may be based on a specific provider implementation.



I know I have worked on combinations of Linq for Object and Linq for XML without any problem.

-2


source







All Articles