开发者

LINQPad: LINQ to SQLite DataContext via System.Data.Sqlite

开发者 https://www.devze.com 2023-01-11 13:44 出处:网络
I\'m fairly new to LINQ and trying to find a more elegant way (other than ADO.Net) to query and manipulate data in a SQLite database. I\'m using System.Data.SQLite and wondering if there is a DataCont

I'm fairly new to LINQ and trying to find a more elegant way (other than ADO.Net) to query and manipulate data in a SQLite database. I'm using System.Data.SQLite and wondering if there is a DataContext class or a way to use DataContext class to work with SQLite.

I believe LINQPad uses the same assembly for its SQLite/MyS开发者_运维知识库QL driver and with it I can execute C# expressions like so:

from c in Collection
where c.Length > 3
select c

What can I do to use those same LINQ expressions with my SQLite databases in my applications?


System.Data.SQLite supports the ADO.NET Entity Framework, so you should be able to just add an Entity Framework mapping and point it to your SQLite connection.

http://sqlite.phxsoftware.com/sqlite.wmv


Basically, Linq-to-SQL as is only support SQL Server as its backend.

You need to look at some third-party extension, like:

  • DBLinq
  • LinqConnect

Those additional tools allow you to use Linq-to-SQL against a variety of backend database stores, including SQLite.

0

精彩评论

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