开发者

Is the DataContext class specific to SQL Server?

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 be开发者_Go百科cause 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜