SQL_ORM框架

【LINQ】
using (SqlConnection conn = new SqlConnection(conStr)) {
string sql = $@"select * from vip_e_coupons_policy where blocno=@blocno";
}

增删改:conn.Execute(sql)
查:conn.Query<T>(sql)

SingleOrDefault():返回值序列的单个特定元素;如果未找到此类元素,则返回默认值。

————————————————————————————————————————————————————————————
【EF CORE】

 API:https://docs.microsoft.com/zh-cn/ef/core/querying/raw-sql?tdsourcetag=s_pctim_aiomsg
————————————————————————————————————————————————————————————

【dapper】
Dapper是.Net下的一个轻量级ORM(Object Relational Mapping 对象关系映射)框架
添加Dapper的Nugets包

————————————————————————————————————————————————————————————
【Sugar】

API:http://www.codeisbug.com/Doc/8/1165

————————————————————————————————————————————————————————————
持久化是将程序数据在持久状态和瞬时状态间转换的机制。
即把数据(如内存中的对象)保存到可永久保存的存储设备中(如磁盘)。
持久化的主要应用是将内存中的对象存储在数据库中,或者存储在磁盘文件中、XML数据文件中等等。

———————————————————————————————————————————————————————————— 

【删除】
当你不再需要该表时,用【drop】
当你仍要保留该表,但要删除所有记录时,用【truncate】
当你要删除部分记录时, 用【delete】

清空表
重置自增字段
truncate table hotel_area restart IDENTITY;
truncate table hotel_device restart IDENTITY;
truncate table hotel_trade_area restart IDENTITY;
truncate table hotel_hot_word restart IDENTITY;
truncate table hotel_optimal restart IDENTITY;
truncate table hotel_pic restart IDENTITY;
truncate table hotel_area;
truncate table hotel_device;
truncate table hotel_trade_area;
truncate table hotel_hot_word;
truncate table hotel_optimal;
truncate table hotel_pic;

猜你喜欢

转载自www.cnblogs.com/mobaiyu/p/11161778.html