时代收藏网,胜利生活社区油城茶座,孤月行
*本文中所用类声明见上一篇博文《轻量orm-sqlrepoex (三)select语句》中customers类
var repository = repofactory.create<customers>();
customers customers = new customers { customerid = "your1", companyname = "你的公司名1", phone = "13900000000" };
repository.insert().for(customers).go();
当前增加的sql语句:
insert[dbo].[customers]([customerid], [companyname], [contactname], [contacttitle], [address], [city], [region], [postalcode], [country], [phone], [fax])
values('your1', '你的公司名1', null, null, null, null, null, null, null, '13900000000', null);
repository.insert().with(m => m.customerid, "your1")
.with(m => m.companyname, "你的公司名1")
.with(m => m.phone, "13900000001").go();
当前增加的sql语句:
insert[dbo].[customers]
([customerid], [companyname], [phone])
values('your1', '你的公司名1', '13900000001');
(1)、如果有自增加字段,需要在对应属性增加[identityfiled] 特性
如: [identityfiled]
public string customerid { get; set; }
(2)则生成时有 identityfiled 特性是的sql语句
insert [dbo].[customers]([companyname], [contactname], [contacttitle], [address], [city], [region], [postalcode], [country], [phone], [fax])
values('你的公司名', null, null, null, null, null, null, null, '1390000000', null);
select [customerid], [companyname], [contactname], [contacttitle], [address], [city], [region], [postalcode], [country], [phone], [fax]
from [dbo].[customers]
where [customerid] = scope_identity();
(3)指定列值增加时有 identityfiled 特性是的sql语句
insert [dbo].[customers]([customerid], [companyname], [phone])
values('your1', '你的公司名1', '13900000001');
select [customerid], [companyname], [phone]
from [dbo].[customers]
where [customerid] = scope_identity();
关于相关特性会在后续博文中介绍
var repository = repofactory.create<customers>();
customers customers = new customers { customerid = "yourc", companyname = "你的公司名", phone = "1390000000" };
repository.update().for(customers).go();
生成的sql语句
update [dbo].[customers]
set [customerid] = 'yourc', [companyname] = '你的公司名', [contactname] = null, [contacttitle] = null, [address] = null, [city] = null, [region] = null, [postalcode] = null, [country] = null, [phone] = '1390000000', [fax] = null where [customerid] = 'yourc', [companyname] = '你的公司名';
repository.update()
.set(m => m.companyname, "你的公司名100")
.set(m => m.phone, "13900000023").where(m => m.customerid == "your1").go())
生成的sql语句
update [dbo].[customers]
set [companyname] = '你的公司名100', [phone] = '13900000023'
where ([dbo].[customers].[customerid] = 'your1');
var repository = repofactory.create<customers>();
customers customers = new customers { customerid = "yourc", companyname = "你的公司名", phone = "1390000000" };
repository.delete().for(customers).go();
生成的sql语句
delete [dbo].[customers] where [customerid] = 'yourc', [companyname] = '你的公司名';
repository.delete().where(m => m.customerid == "your1").go();
生成的sql语句
delete [dbo].[customers]
where ([dbo].[customers].[customerid] = 'your1');
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论