.net - AssociationSet in EF4 -


i beginner in ef4 , , not able understand in .edmx file ,

could explain me benefit of associationset ,i think association element represents relationship between tables , why should use associationset .

thanks,

the associationset container association.

lets began simle case when have contract , address types. relationship described in xml like:

<association name="fk_address_contact">   <end role="contact" type="samplemodel.contact" multiplicity="1">     <ondelete action="cascade" />   </end>   <end role="address" type="samplemodel.address" multiplicity="*" />   <referentialconstraint>     <principal role="contact">       <propertyref name="contactid" />     </principal>     <dependent role="address">       <propertyref name="contactid" />     </dependent>   </referentialconstraint> </association> 

as can see here, 1 contact can have many addresses. here describe there exists reference between 2 types. how can describe case when in contract type can have, actually, 2 or more addresses. example, workaddress , homeaddress. within association can describe fact 2 types have referenced each other, within associationset can describe 1 type use 2 equal references other type.

for such case can define next xml:

<entitycontainer name="contactscontainer" >   <entityset name="workcontacts" entitytype="samplemodel.contact" />   <entityset name="homecontacts" entitytype="samplemodel.contact" />   <entityset name="workaddresses" entitytype="samplemodel.address" />   <entityset name="homeaddresses" entitytype="samplemodel.address" />   <associationset name="toworkaddress" association="samplemodel.fk_address_contact">     <end role="contact" entityset="workcontacts" />     <end role="address" entityset="workaddresses" />   </associationset>   <associationset name="tohomeaddress" association="samplemodel.fk_address_contact">     <end role="contact" entityset="homecontacts" />     <end role="address" entityset="homeaddresses" />   </associationset> </entitycontainer> 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -