-
Notifications
You must be signed in to change notification settings - Fork 861
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
1.8.0 新功能 BeginEdit 编辑数据功能讨论 #397
Comments
666, 重构winfom的我正好用得上 |
666.很实用的功能 |
如果存在脏数据呢?会有相关异常吗?例如有另外的用户把你要修改的那条记录提前给删除了. |
如果有这个要求,可以用事务级别来控制,把行锁(for update)住再操作,最高可以锁表。 |
仓储 BeginEdit/EndEdit 测试代码: [Fact]
public void BeginEdit()
{
fsql.Delete<BeginEdit01>().Where("1=1").ExecuteAffrows();
var repo = fsql.GetRepository<BeginEdit01>();
var cts = new[] {
new BeginEdit01 { Name = "分类1" },
new BeginEdit01 { Name = "分类1_1" },
new BeginEdit01 { Name = "分类1_2" },
new BeginEdit01 { Name = "分类1_3" },
new BeginEdit01 { Name = "分类2" },
new BeginEdit01 { Name = "分类2_1" },
new BeginEdit01 { Name = "分类2_2" }
}.ToList();
repo.Insert(cts);
repo.BeginEdit(cts);
cts.Add(new BeginEdit01 { Name = "分类2_3" });
cts[0].Name = "123123";
cts.RemoveAt(1);
Assert.Equal(3, repo.EndEdit());
}
class BeginEdit01
{
public Guid Id { get; set; }
public string Name { get; set; }
} 执行的 SQL: INSERT INTO "BeginEdit01"("Id", "Name")
VALUES('5f26bf00-6ac3-cbe8-00da-7dd01be76e26', '分类1'),
('5f26bf00-6ac3-cbe8-00da-7dd11bcf54dc', '分类1_1'),
('5f26bf00-6ac3-cbe8-00da-7dd205be550b', '分类1_2'),
('5f26bf00-6ac3-cbe8-00da-7dd3783095b1', '分类1_3'),
('5f26bf00-6ac3-cbe8-00da-7dd41cad690f', '分类2'),
('5f26bf00-6ac3-cbe8-00da-7dd549f45025', '分类2_1'),
('5f26bf00-6ac3-cbe8-00da-7dd6039c34d2', '分类2_2')
INSERT INTO "BeginEdit01"("Id", "Name") VALUES('5f26bf07-6ac3-cbe8-00da-7dd74818c3a6', '分类2_3')
UPDATE "BeginEdit01" SET "Name" = '123123'
WHERE ("Id" = '5f26bf00-6ac3-cbe8-00da-7dd01be76e26')
DELETE FROM "BeginEdit01" WHERE ("Id" = '5f26bf00-6ac3-cbe8-00da-7dd11bcf54dc') |
好像有bug, 补充测试结果: 每次repos.EndEdit() 后 都跟了 repos.BeginEdit(_orderDetails)
执行结果
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
上面的代码在 EndEdit 方法执行的时候产生 3 条 SQL 如下:
场景:winform 加载表数据后,一顿添加、修改、删除操作之后,点击【保存】
The text was updated successfully, but these errors were encountered: