且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在LINQ to SQL DataContext中“自动插入"主键.部分方法

更新时间:2022-05-27 01:09:31

我真的建议让SQL Server进行增量编号.即使您确实使用了上面的方法,在多用户情况下(他们都获得相同的ID并尝试插入相同的ID),这种方法在负载下也会失败.

I would really recommend letting SQL Server do the incremental numbering. The above approach even if you do get it working would fail under load in a multi-user scenario where they both get the same ID and try to insert the same one.