当前位置:网站首页>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();
边栏推荐
- Data center table reports realize customized statistics, overtime leave summary record sharing
- 10 minutes to master the installation steps of MySQL
- How to modify / display GPIO status through ADB shell
- C语言课程设计
- Construction and management practice of ByteDance buried point data flow
- 事件监听机制
- 3.1 simple condition judgment
- 事务的隔离级别详解
- Autodesk Navisworks 2022软件安装包下载及安装教程
- # Cesium实现卫星在轨绕行
猜你喜欢

The two trump brand products of Langjiu are resonating in Chengdu, continuously driving the consumption wave of bottled liquor

10 minutes to master the installation steps of MySQL

d3dx9_ How to repair 38.dll? d3dx9_ 38. How to download a missing DLL?

Source NAT address translation and server mapping web page configuration of firewall Foundation

Determine the maximum number of specific words in a string

d3dx9_ How to repair 25.dll? d3dx9_ 25.dll where to download

一个机器人位于一个 m x n 网格的左上角 。机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角。问总共有多少条不同的路径?【LeetCodeHot100】

d3dx9_ 39.dll how to repair -d3dx9_ 39.dll missing file download

# Cesium实现卫星在轨绕行

【多线程】线程通信调度、等待集 wait() 、notify()
随机推荐
Autodesk Navisworks 2022软件安装包下载及安装教程
Ti Click: quickly set up tidb online laboratory through browser | ti- team interview can be conducted immediately
关于VS2019C#如何建立登陆界面输入的用户名和密码需与Access数据库的记录相匹配
数组表示若干个区间的集合,请你合并所有重叠的区间,并返回 一个不重叠的区间数组,该数组需恰好覆盖输入中的所有区间 。【LeetCodeHot100】
2022年中国音频市场年度综合分析
[multithreading] thread communication scheduling, waiting set wait(), notify()
Under the influence of external factors, how to manage internal resources and reduce costs is the key
How to modify / display GPIO status through ADB shell
A robot is located in the upper left corner of an M x n grid. The robot can only move down or right one step at a time. The robot attempts to reach the lower right corner of the grid. How many differe
National food safety risk assessment center: do not blindly and unilaterally pursue "zero addition" and "pure natural" food
Leetcode daily practice (Yanghui triangle)
数据中心表格报表实现定制统计加班请假汇总记录分享
#yyds干货盘点# 解决剑指offer:二叉树中和为某一值的路径(三)
米哈游起诉五矿信托,后者曾被曝产品暴雷
阿里云刘珅孜:云游戏带来的启发——端上创新
一个机器人位于一个 m x n 网格的左上角 。机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角。问总共有多少条不同的路径?【LeetCodeHot100】
Oracle概念二
Community sharing jumpserver in the eyes of senior open source users: a fortress machine for "Crazy" iteration
Huawei cloud devcloud launched four new capabilities, setting two domestic firsts
Oracle概念三