views:

43

answers:

2

The MSDN page for the DataContext class says:

Represents the main entry point for the LINQ to SQL framework.

Yet it looks like the constructors will take any ADO.NET IDBConnection. Am I right in thinking that a DataContext can wrap any ADO.NET connection? Or are there special things that need to be considered when using a connection to a data source other then SQL Server?

The remarks section of the MSDN article on the DataContext class say:

The DataContext is the source of all entities mapped over a database connection. It tracks changes that you made to all retrieved entities and maintains an "identity cache" that guarantees that entities retrieved more than one time are represented by using the same object instance.

For example could I use a DataContext to read and update a SQLLite database by creating the DataContext with the System.Data.SQLite provider?

It's just a little confusing because it seems like everything I see written about Linq always also mentions SQL Server, but I'm never sure if that's just on example or if SQL Server is the only database that will work.

+2  A: 

DataContext is part of LINQ to SQL. LINQ to SQL is specific to SQL Server.

Perhaps you should look into Entity Framework, which is meant to support multiple databases.

John Saunders
+2  A: 

While DataContext (as shipped with regular .NET) is intended for use with LINQ-to-SQL, there are other implementations, such as DbLinq (now used in Mono) which supports multiple databases.

A SQLLite example is on the Mono page.

Marc Gravell
DbLinq is an interesting one. I've never heard of it before. Have you got any idea about the quality of DbLinq compared to LINQ to SQL. For instance, how is it performing? Does it generate SQL queries with the same quality as LINQ to SQL does? Is it able to handle complex LINQ queries (using `Contains`, `StartsWith`, `EndsWith` string operators and `Contains` collection operators, complex joins, complex groupings, complex unions)?
Steven
@Steven - I haven't done an exhaustive comparison, I'm afraid.
Marc Gravell