首页 新闻 会员 周边

关于EF导航属性的问题

0
悬赏园豆:5 [已解决问题] 解决于 2017-12-28 11:17

刚开始学习EF,在阅读别人代码的时候看到导航属性,网上没有找到关于导航属性的详细说明,只知道是设置多表关联的,代码如下

/// <summary>
/// 
/// </summary>
[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("Gift163DBModel", "FK_PRODUCTT_REFERENCE_PRODUCTT", "ProductTypes1")]
public EntityCollection<ProductTypes> ProductTypes1
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<ProductTypes>("Gift163DBModel.FK_PRODUCTT_REFERENCE_PRODUCTT", "ProductTypes1");
}
set
{
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<ProductTypes>("Gift163DBModel.FK_PRODUCTT_REFERENCE_PRODUCTT", "ProductTypes1", value);
}
}
}

 




数据库表中没有ProductTypes1这个字段,请问这段代码是EF自动生成的还是手写的呢?

调用代码如下

public ActionResult LeftTree()
{
var items = _ProductTypesBLL.Get().Where(a=>a.ProductTypes2.Name.Equals("按地域分")).Take(11);
return View(items);
}
ludi的主页 ludi | 初学一级 | 园豆:5
提问于:2015-10-28 11:23
< >
分享
最佳答案
0

请楼主参考微软官方文档 https://msdn.microsoft.com/zh-cn/data/jj713564.aspx                                  酷站网软

收获园豆:5
FreePress | 菜鸟二级 |园豆:218 | 2015-10-29 13:08
其他回答(1)
0

导航属性不是字段.

吴瑞祥 | 园豆:29449 (高人七级) | 2015-10-28 11:56

这些导航属性是EF自动生成的吗?

支持(0) 反对(0) ludi | 园豆:5 (初学一级) | 2015-10-28 13:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册