- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
前段时间我问了这个问题:What is the purpose of each of the System.ComponentModel.DataAnnotations attributes?
但是,我没有得到回复的运气。从要求提供有关每个数据注释属性的文档的意义上来说,这个问题有点宽泛。目前,我对Association
属性最感兴趣。
我正在将ASP.NET MVC3与Entity Framework 4一起使用,并想对我的POCO进行注释。我在POCO中使用了外键(感觉有点不对劲,但似乎通常可以使用)。如何用Association
属性注释POCO?我应该放在哪些属性上(Association
属性和/或外键属性)?什么是thisKey
和otherKey
参数。 thisKey
是此POCO key ,还是此POCO中的外键?
最后,什么将使用此属性? ASP.NET MVC中有东西吗?
提前致谢!
最佳答案
Silverlight中的WCF RIA服务使用AssociationAttribute(与ExternalReferenceAttribute结合使用)。使用此属性,客户端可以解析来自不同域的实体之间的关联。
我认为它特定于RIA服务。 Here演练了如何在WCF RIA服务中应用它。
一个简单的例子看起来像
public class Customer{
public int Id {get;set;}
}
public class Order{
public int Id {get;set;}
public int CustomerId {get;set;} //ForeignKey of the Customer
[ExternalReference]
[Association("Customer", "CustomerId", "Id")]
public Customer {get;set;}
}
关于asp.net-mvc-3 - 我如何使用System.ComponentModel.DataAnnotations.AssociationAttribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5389603/
我试图了解我是否可以在 EntityFramework 中以某种方式使用 AssociationAttribute。 MSDN 文档薄弱。 我在这里找到了一个不确定的答案: How do I use
前段时间我问了这个问题:What is the purpose of each of the System.ComponentModel.DataAnnotations attributes? 但是,
我是一名优秀的程序员,十分优秀!