开发者

linq to sql insert when record is already present

I have an object开发者_运维问答 that has a property called ObjectID that maps to the primary key of a table in the DB.

What happens if you do a linq-to-sql insert and attempt to do an insert with an object with an ObjectID already present in the DB?

Thanks.


after test:
if the entity you trying to insert new to the datacontext even if the primarykey value already exists it will insert a new entity with new ID

if the entity you trying to insert is pulled from the same datacontext then it will throws this exception Cannot add an entity that already exists.

anyway you can try it by yourself to insure this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜