当前位置:网站首页>SQLite net (SQLite is used by unity, WPF and WinForm)
SQLite net (SQLite is used by unity, WPF and WinForm)
2022-06-27 16:55:00 【Wheezing】
Reference package
Search for sqlite-net Package and reference into the project ,unity Direct copy SQLite、SQLiteAsync Just go to the project
Add management class
public static class DatabaseHandler
{
private static string connstr = UnityEngine.Application.streamingAssetsPath + "/data.db"; // No database will create a database
public static SQLiteConnection db;
public static SQLiteAsyncConnection dbAsync;
static DatabaseHandler()
{
db = new SQLiteConnection(connstr, false);
dbAsync = new SQLiteAsyncConnection(connstr, false);
db.CreateTable<User>();
}
public static int Add(object model)
{
return db.Insert(model);
}
public static async Task<int> AddAsync(object model)
{
return await dbAsync.InsertAsync(model);
}
public static int Update(object model)
{
return db.Update(model);
}
public static async Task<int> UpdateAsync(object model)
{
return await dbAsync.UpdateAsync(model);
}
public static int Delete(object model)
{
return db.Delete(model);
}
public static async Task<int> DeleteAsync(object model)
{
return await dbAsync.DeleteAsync(model);
}
public static List<T> Query<T>(string sql) where T : new()
{
return db.Query<T>(sql);
}
public static async Task<List<T>> QueryAsync<T>(string sql) where T : new()
{
return await dbAsync.QueryAsync<T>(sql);
}
public static int Execute(string sql)
{
return db.Execute(sql);
}
public static async Task<int> ExecuteAsync(string sql)
{
return await dbAsync.ExecuteAsync(sql);
}
public static TableQuery<T> Table<T>() where T : new()
{
return db.Table<T>();
}
public static AsyncTableQuery<T> TableAsync<T>() where T : new()
{
return dbAsync.Table<T>();
}
}
[Table("user")]
public class User
{
[PrimaryKey, AutoIncrement]
[Column("id")]
public int Id {
get; set; }
[Column("name")]
public string Name {
get; set; }
}
Use
var users = await DatabaseHandler.TableAsync<User>().Where(x => x.Name == " test ")
.ToListAsync();
边栏推荐
- Oracle概念二
- About how vs2019c # establishes the login interface, the user name and password entered must match the records in the access database
- 深耕数字化,引领云原生,服务更多开发者
- The two trump brand products of Langjiu are resonating in Chengdu, continuously driving the consumption wave of bottled liquor
- QT5.5.1桌面版安装配置过程中的疑难杂症处理(配置ARM编译套件)
- Leetcode daily practice (sum of two numbers)
- 全面解析零知识证明:消解扩容难题 重新定义「隐私安全」
- 跨域图像的衡量新方式Style relevance:论文解读和代码实战
- Hung - Mung! HDD Hangzhou station · salon hors ligne vous invite à construire l'écologie
- National food safety risk assessment center: do not blindly and unilaterally pursue "zero addition" and "pure natural" food
猜你喜欢

3.2 multiple condition judgment

Hongmeng makes efforts! HDD Hangzhou station · offline salon invites you to build ecology

2022年中国音频市场年度综合分析

Construction and management practice of ByteDance buried point data flow

Oracle概念二

Unity shadow shadow pancaking

Oracle concept II

树莓派初步使用

10分钟掌握mysql的安装步骤

EMQ 助力青岛研博建设智慧水务平台
随机推荐
Hongmeng makes efforts! HDD Hangzhou station · offline salon invites you to build ecology
3.4 fixed number of cycles II
Nemo of pulseaudio (22)
C language teacher workload management system
Mobile terminal click penetration
【Pygame小遊戲】這款“吃掉一切”遊戲簡直奇葩了?通通都吃掉嘛?(附源碼免費領)
What should the ultimate LAN transmission experience be like
Detailed explanation of transaction isolation level
#yyds干货盘点# 解决剑指offer:二叉树中和为某一值的路径(三)
Mode setting of pulseaudio (21)
C language course design
Impressive questions
10 minutes to master the installation steps of MySQL
How to modify / display GPIO status through ADB shell
d3dx9_ How to repair 25.dll? d3dx9_ 25.dll where to download
Array represents a collection of several intervals. Please merge all overlapping intervals and return a non overlapping interval array. The array must exactly cover all the intervals in the input. 【Le
EMQ 助力青岛研博建设智慧水务平台
Huawei cloud devcloud launched four new capabilities, setting two domestic firsts
Qt5 signal and slot mechanism (demonstrate the correlation between the control's own signal and slot function)
Smart wind power | Tupu software digital twin wind turbine equipment, 3D visual intelligent operation and maintenance