Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PartMain - o:m Section, o:m Report
- PartSection - m:o Main, o:m Property
- PartProperty - m:o Section, Contains MainID for sorting purposes, SortByMainID
- PartReport - m:o Main
- PartMain: Name, Desc, etc... rest of data
- PartSection1: data...
- PartProperty1: data.. (all properties in relationship with that section)
- PartSection2: data... (all sections in relationship with selected PartMain)
- PartProperty1: data.. (all properties in relationship with that section)
- PartReport: data.... (all reports with selected PartMain)
- pMainID = selectedMainID;
- PartMain partMain = db.PartMain.Find(pMainID);
- ViewBag.Name = partMain.Name
- ViewBag.Desc = partMain.Desc
- var partSections = db.PartSection.Where(s => s.pMainID = pMainID);
- foreach (var partSec in partSections)
- {
- ViewBag.PartSecName = partSec.Name
- ViewBag.PartSecDesc = partSec.Desc
- var partProperties = db.PartProperties.Where(p => p.pSecID = partSec.ID);
- foreach(var partProp in partProperties)
- {
- ViewBag.PartPropName = partProp.Name
- ViewBag.PartPropDesc = partProp.Desc
- }
- }
- var pMainID = selectedMainID;
- PartMain partMain = db.PartMain.Find(pMainID);
- ViewBag.Part = partMain;
- ViewBag.Sections = db.PartSection
- .Where(s => s.pMainID = pMainID)
- .Select(s => new
- {
- Section = s,
- Proeprties = db.PartProperties.Where(p => p.pSecID = partSec.ID)
- });
- <h1>@ViewBag.Part.Name</h1>
- <p>@ViewBag.Part.Desc</p>
- @foreach(var section in ViewBag.Sections)
- {
- <h2>@section.Section.Name</h2>
- <p>@section.Section.Desc</p>
- <dl>
- @foreach(var property in section.Properties)
- {
- <dt>@property.Name</dt>
- <dd>@property.Desc</dd>
- }
- </dl>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement