2013-02-22 9 views
5

मैं उपयोग कर रहा हूँ इकाई की रूपरेखा 5 कोड सबसे पहले और मैं निम्नलिखित मॉडल है:कई परस्पर अनन्य माता पिता संस्थाओं के साथ इकाई की रूपरेखा 5 कोड पहले बच्चे इकाई में की पहचान संबंध मैप करने के लिए कैसे

class Document 
{ 
    public int Id {get;set;} 
    public String Name {get;set;} 

    public IList<Page> Pages {get;set;} 
} 

class DocumentTemplate 
{ 
    public int Id {get;set;} 
    public String Description {get;set;} 
    public String Name {get;set;} 

    public IList<Page> Pages {get;set;} 
} 

class Page 
{ 
    public int Id {get;set;} 
    public string Text {get;set;} 
} 

मुझे पता है कि मैप करने के लिए एक पहचान संबंध जहां बाल इकाई के 1 माता-पिता हैं। लेकिन मैं पृष्ठ इकाई को मैप करना चाहता हूं ताकि प्रत्येक माता-पिता के लिए इसका एक पहचान हो।

इसके अलावा, माता-पिता संबंध पारस्परिक रूप से अनन्य हैं। एक विशेष पृष्ठ या तो दस्तावेज़ टेम्पलेट या दस्तावेज़ से संबंधित होगा, दोनों नहीं।

क्या ऐसी मैपिंग इकाई फ्रेमवर्क 5 में संभव है?

मैं एक पृष्ठ के लिए अलग-अलग संस्थाएं नहीं बनाना चाहता, क्योंकि वे मूल संबंधों को छोड़कर अनिवार्य रूप से वही होंगे।

टीआईए।

उत्तर

0

मुझे नहीं लगता कि आप एक से अधिक माता पिता हो सकता है, लेकिन मैं निम्नलिखित विकल्प पर विचार करेंगे:
(कोई भी दस्तावेज़ कुछ-टेम्पलेट के हैं, केवल टेम्पलेट्स पृष्ठों हो सकता है)

class Document 
{ 
    public int Id {get;set;} 
    public String Name {get;set;} 
    public DocumentTemplate DocumentTemplate{get;set;} 
} 

class DocumentTemplate 
{ 
    public int Id {get;set;} 
    public String Description {get;set;} 
    public String Name {get;set;} 

    public IList<Page> Pages {get;set;} 
} 

class Page 
{ 
    public int Id {get;set;} 
    public string Text {get;set;} 
} 
0

इस काम करेगा आपके लिए:

class Page 
{ 
    public int Id {get;set;} 
    public string Text {get;set;} 

    public int? DocumentId { get; set; } // non-mandatory relationship to Document 
    public int? DocumentTemplateId { get; set; } // non-mandatory relationship to DocumentTemplate 

    // ... navigation properties 
} 
संबंधित मुद्दे