-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
batch insert #32
Comments
@HuUncle <Statement Id="InsertBatch">
INSERT INTO T_Entity
(FString
,FDecimal
,FNullDecimal
,FBool
,FNullBool
,Status
,NullStatus
,CreationTime
,LastUpdateTime)
VALUES
<For Open="" Close="" Key="T" Property="Items" Separator=",">
(@FString
,@FDecimal
,@FNullDecimal
,@FBool
,@FNullBool
,@Status
,@NullStatus
,@CreationTime
,@LastUpdateTime)
</For>
</Statement> var items = new List<T_Entity> {
new T_Entity
{
CreationTime = DateTime.Now,
FBool = true,
FDecimal = 1,
FLong = 1,
FNullBool = false,
FString = Guid.NewGuid().ToString("N"),
FNullDecimal = 1.1M,
LastUpdateTime = DateTime.Now,
Status = EntityStatus.Ok
},new T_Entity
{
CreationTime = DateTime.Now,
FBool = true,
FDecimal = 1,
FLong = 1,
FNullBool = false,
FString = Guid.NewGuid().ToString("N"),
FNullDecimal = 1.1M,
LastUpdateTime = DateTime.Now,
Status = EntityStatus.Ok
}
};
_sqlMapper.Execute(new RequestContext
{
Scope = Scope,
SqlId = "InsertBatch",
Request = new { Items = items }
}); |
方法不错 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请问批量添加功能如何实现呢,我参照文档的 这样子的写法,这样子会有异常抛出,提示For 的Key 键不能为空!
INSERT INTO T_Test
(Name,Status)
VALUES
(@name,@Status)
我觉得批量添加在开发中还是会经常用到,比方说做Excel导入时,订单项添加时,都会用到批量添加,希望作者能够写一些示例。我查阅了SmartSqlStarter项目,内容较少也没有涉及到批量操作的功能。
Thanks
The text was updated successfully, but these errors were encountered: