One-to-multiple nhing in nhib -- bidirectional Association

Source: Internet
Author: User

One-to-multiple nhing in nhib -- bidirectional Association

 

The difference between two-way Association and one-way association is that both sides can maintain the relationship. For example, if I query any side of the two sides, the information on the other side can also be queried. If I delete other modifications, I only need to set them, or both. It is embodied in the Code: because the previous one-way Association is on DictionaryEntity, it is necessary to add Association ing to the DictionTypeEntity and its corresponding xml file.

 

Change DictionaryEntity:

 

# Region object attributes ////// Type ///Public virtual string Type {get; set ;}////// Type name ///Public virtual string TypeName {get; set ;}////// Timestamp ///Public virtual string TimeStamp {get; set ;}////// Operation user ///Public virtual string AddUser {get; set ;}////// Dictionary Object list set ///Public virtual IList
 
  
DictionaryEntitys {get; set;} # endregion
 


 

Xml file corresponding to DictionaryEntity:

 

 

 

At this point, if we query the information of DictionaryEntity and want to know the Value of DictionaryTypeEntity, We can query the Value we want in DictionaryEntity. DictionaryType. Value. If we want to save the DictionaryEntity message

You must first instantiate a DictionaryTypeEntity and assign it to DictionaryEntity. DictionaryType. As follows:


 

 

DictionaryTypeEntity enDictionaryType=new DictionaryTypeEntity();DictionaryEntity enDictionary=new DictionaryEntity();enDictionary.DictionaryType=enDictionaryType;

In this way, the error "object not instantiated" will not be reported. This is much simpler to avoid the previous joint query.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.