开发者

What is the purpose of the AssociationAttribute in DataAnnotations?

I'm trying to understand if I can use the AssociationAttribute in some way 开发者_Python百科in EntityFramework. The MSDN documentation weak.

I found an inconclusive answer here:

How do I use System.ComponentModel.DataAnnotations.AssociationAttribute

If it is possible, please provide me some usage example.


From what I read, the AssociationAttribute is used to describe your business objects that are associated via business logic, but come from completely different data context (mde files).

For example, if your customer class is loaded from the CustomersContext, but the customer class contains an address object which resides in a different data Ccontext, you would decorate the address property within the customer class with this AssociationAttribute to describe, "HEY! load this from the data context with the name I have provided in the attribute!"

Basically, the framework will delegate the crud stuff to the associated data context for the address property.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜