15

What is a "LINQ provider," and what is its purpose?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
user366312
  • 16,949
  • 65
  • 235
  • 452

2 Answers2

18

A linq provider is software that implements the IQueryProvider and IQueryable interfaces for a particular data store. In other words, it allows you to write Linq queries against that data store. For example, the Linq to XML provider allows you to write Linq queries against XML documents.

You can also write your own Linq provider, although it is not trivial. See Building an Iqueryable Provider and Walkthrough: Creating an IQueryable LINQ Provider for more information.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • I think that implementing IQueryable is a rather limited definition. You can use LINQ query expressions against *anything* that defines an appropriate Select method (it doesn't even need to implement any interfaces, because of compile time duck typing) or the other methods that are part of query expressions (Where, Join, GroupJoin, etc). – JulianR Oct 14 '09 at 19:52
3

"LINQ (Language Integrated Query) works as a middle tier between data store and the language environment. From a developer's point of view, it is just a new pattern for querying data from multiple data structures directly in the IDE. Behind the scenes it does a whole lot of tasks like expression processing, validation and calling the right routine to fetch data or build a query to run in SQL Server. In short, LINQ stands as common query gateway between the language and the data store." http://dotnetslackers.com/articles/csharp/LINQProviderBasics.aspx

A particular gateway for a particular data store (e.g. xml files, sql rdmbs) is called a LINQ Provider. It is realised by implementing the IQueryable Interface.

Matt Waren has a great tutorial series on implementing a cusotm linq provider.

Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172