开发者

Check if object is in context entity framework

开发者 https://www.devze.com 2023-02-01 23:50 出处:网络
Is it possible to开发者_运维技巧 check that an object is in the contextbefore trying to delete that from context ?

Is it possible to开发者_运维技巧 check that an object is in the context before trying to delete that from context ?

thanks for help


Yes, something like:

var key = myContext.CreateEntityKey("Table", myObject);

if (myContext.TryGetObjectByKey(key, out otherObject))
{
     // delete or edit otherObject
}

But you find in /delete from the database, not (just) the context.

0

精彩评论

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