开发者

EF return parent entity only

开发者 https://www.devze.com 2023-04-07 05:11 出处:网络
I\'m having an issue when trying to serialise an entity. An error is being through saying that the query may result in a circular query. Ideally I just want to pull out the entity with no relationship

I'm having an issue when trying to serialise an entity. An error is being through saying that the query may result in a circular query. Ideally I just want to pull out the entity with no relationships attached. I've seen some examples开发者_JAVA技巧 where you can set the relation accessor to Internal but this causes other issues. Is there a way to do this in straight LINQ?

Thanks for the help.


Try returning a single entity using FirstOrDefault()

The reason that you are getting the circular error is probably due to your data model where a row points to the parent which could be the same row.

0

精彩评论

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