刚开始学习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); }
相关分类