sqlite net
时间: 2023-12-29 15:04:15 浏览: 30
根据提供的引用[1],SQLite.NET是一个用于访问SQLite数据库的.NET库。它提供了一个轻量级的ORM框架,可以将.NET对象映射到SQLite数据库中的表和列。SQLite.NET支持LINQ查询,还提供了一些其他的查询和操作SQLite数据库的方法。
以下是一个使用SQLite.NET连接到SQLite数据库并执行查询的示例:
```csharp
using System.Data.SQLite;
// 连接到SQLite数据库
string connectionString = "Data Source=database.db;Version=3;";
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
connection.Open();
// 执行查询
string sql = "SELECT * FROM mytable";
using (SQLiteCommand command = new SQLiteCommand(sql, connection))
{
using (SQLiteDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
// 处理查询结果
int id = reader.GetInt32(0);
string name = reader.GetString(1);
int age = reader.GetInt32(2);
Console.WriteLine("id: {0}, name: {1}, age: {2}", id, name, age);
}
}
}
}
```