Entity Framework 4: Access current datacontext in partial entity class

后端 未结 2 1828
逝去的感伤
逝去的感伤 2021-01-12 03:44

I want to extend an EF entity in a partial class with methods and properties. I\'ve done this quite often. But now I would need to combine data from this entity with data fr

2条回答
  •  臣服心动
    2021-01-12 04:43

    There is no build in way to get current ObjectContext from entity. Entities based on EntityObject class and POCO proxies uses ObjecContext internally but they don't expose it.

    Adding such depnedency into your entities is considered as bad design so you should perhaps explain what you are trying to do and we can find other (better) solution.

提交回复
热议问题