Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: OData model builder should reuse association for bi-direction navigation properties [623]

$
0
0
Association should represent a bi-direction relationship of two entities. It doesn't make sense to have two associations for bidirection navigation properties. <br /><br />For example, in odata service sample, it has model:<br /><br />public class ProductFamily<br />{<br /> public Collection<Product> Products;<br />}<br />public class Product<br />{<br /> public ProductFamily Family;<br />}<br /><br />The generated associations are:<br /> <EntityType Name="Product"><br /> <NavigationProperty Name="Family" Relationship="ODataService.Models.ODataService_Models_Product_Family_ODataService_Models_ProductFamily_FamilyPartner" ToRole="Family" FromRole="FamilyPartner" /><br /> </EntityType><br /> <EntityType Name="ProductFamily"><br /> <NavigationProperty Name="Products" Relationship="ODataService.Models.ODataService_Models_ProductFamily_Products_ODataService_Models_Product_ProductsPartner" ToRole="Products" FromRole="ProductsPartner" /><br /> </EntityType><br /> <Association Name="ODataService_Models_Product_Family_ODataService_Models_ProductFamily_FamilyPartner"><br /> <End Type="ODataService.Models.ProductFamily" Role="Family" Multiplicity="0..1" /><br /> <End Type="ODataService.Models.Product" Role="FamilyPartner" Multiplicity="0..1" /><br /> </Association><br /> <Association Name="ODataService_Models_ProductFamily_Products_ODataService_Models_Product_ProductsPartner"><br /> <End Type="ODataService.Models.Product" Role="Products" Multiplicity="*" /><br /> <End Type="ODataService.Models.ProductFamily" Role="ProductsPartner" Multiplicity="0..1" /><br /> </Association><br /><br />The expected behavior should only generate one association that describe product family and product are one to many relationship. Each navigation property reuse the association but switching FromRole and EndRole to represent the association direction.<br /><br />For example, the odata sample service shows following $metadata with similar models:<br /> <EntityType Name="Product"><br /> <NavigationProperty Name="Category" Relationship="ODataDemo.Product_Category_Category_Products" FromRole="Product_Category" ToRole="Category_Products" /><br /> </EntityType><br /> <EntityType Name="Category"><br /> <NavigationProperty Name="Products" Relationship="ODataDemo.Product_Category_Category_Products" FromRole="Category_Products" ToRole="Product_Category" /><br /> </EntityType><br /> <Association Name="Product_Category_Category_Products"><br /> <End Role="Product_Category" Type="ODataDemo.Product" Multiplicity="*" /><br /> <End Role="Category_Products" Type="ODataDemo.Category" Multiplicity="0..1" /><br /> </Association><br /><br />The issue happens in both convention and explicit model builder.<br /><br />

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>