且构网

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

Linq To Sql-主键语法

更新时间:2023-08-29 14:06:16

Identity表示ID列具有自动生成的值,该值将在任何插入时自动插入.第一次插入行时,ID的值将为1,下次为2,以此类推.

Identity means that the ID column has an autogenerated value that will be inserted automatically on any insert. When you insert a row the first time the value for ID will be 1 the next time 2 and so on.

自动同步指示公共语言运行库(CLR)在插入或更新操作之后检索该值.

AutoSync Instructs the common language runtime (CLR) to retrieve the value after an insert or update operation.

选项:始终,从不,OnUpdate,OnInsert.

来源

从不:只要您不从数据库中加载实体,您就永远不会取回ID.始终意味着在每次插入或更新Linq2Sql操作之后,它将从数据库中检索值.

Never: You will never get back an ID in your entity (as long as you won't load the Entity from Database). Always means that after every insert or update Linq2Sql operation it will retrieve the value from the Database.