引入命名空间
using System.Data.Linq;
using Mono.Data.Sqlite;
编写代码
var conn = new SqliteConnection(ConfigurationManager.AppSettings["dbstring2"]);
var db = new DataContext(conn);
List<Test> obj = db.ExecuteQuery<Test>("select * from test").ToList();
Console.WriteLine(obj.Count);
dbstring2格式:
<add key="dbstring2" value="DbLinqProvider=qlite;Data Source=C:\Users\darren\Downloads\SQLiteSpy_1.9.11\mytest.db3"/>
使用DataContext操作SQLite详细步骤
大道至简