gpt4 book ai didi

c# - 哪个.Net ORM支持批量插入/更新/删除之类的sql?

转载 作者:行者123 更新时间:2023-11-30 19:48:44 37 4
gpt4 key购买 nike

哪个ORM支持批量插入/更新/删除之类的sql:

var user=new UserInfoFields();
var update=user.Update().Set
(
user.Field1=1,
user.Field2="xxxx"
).Where(user.Name=="Jim" && user.Enable==true);

update.Excute();

对应的T-sql为:

UPDATE UserInfo 
SET
Field1=1,
Field2="xxxx"
WHERE Name='Jim' and Enable=1

最佳答案

checkout BLToolkit -> BLToolkit Linq Extensions - Update

db.Employee
.Where(e => e.Title == "Spectre")
.Update(e => new Northwind.Employee
{
Title = "Commander"
});

db.Employee
.Where(e => e.Title == "Spectre")
.Set(e => e.Title, "Commander")
.Update();

=

UPDATE
[e]
SET
[Title] = 'Commander'
FROM
[Employees] [e]
WHERE
[e].[Title] = 'Spectre'

现在已经使用它 2-3 年了,它很棒 :D

首先阅读这个 -> High Level Vision, Global Architecture Strategy & Concept Model Design

关于c# - 哪个.Net ORM支持批量插入/更新/删除之类的sql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5106633/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com