Advertisement
Guest User

Untitled

a guest
Mar 16th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. PartMain - o:m Section, o:m Report
  2. PartSection - m:o Main, o:m Property
  3. PartProperty - m:o Section, Contains MainID for sorting purposes, SortByMainID
  4. PartReport - m:o Main
  5.  
  6. PartMain: Name, Desc, etc... rest of data
  7. PartSection1: data...
  8. PartProperty1: data.. (all properties in relationship with that section)
  9. PartSection2: data... (all sections in relationship with selected PartMain)
  10. PartProperty1: data.. (all properties in relationship with that section)
  11. PartReport: data.... (all reports with selected PartMain)
  12.  
  13. pMainID = selectedMainID;
  14. PartMain partMain = db.PartMain.Find(pMainID);
  15. ViewBag.Name = partMain.Name
  16. ViewBag.Desc = partMain.Desc
  17.  
  18. var partSections = db.PartSection.Where(s => s.pMainID = pMainID);
  19.  
  20. foreach (var partSec in partSections)
  21. {
  22. ViewBag.PartSecName = partSec.Name
  23. ViewBag.PartSecDesc = partSec.Desc
  24.  
  25. var partProperties = db.PartProperties.Where(p => p.pSecID = partSec.ID);
  26. foreach(var partProp in partProperties)
  27. {
  28. ViewBag.PartPropName = partProp.Name
  29. ViewBag.PartPropDesc = partProp.Desc
  30. }
  31. }
  32.  
  33. var pMainID = selectedMainID;
  34. PartMain partMain = db.PartMain.Find(pMainID);
  35.  
  36. ViewBag.Part = partMain;
  37.  
  38. ViewBag.Sections = db.PartSection
  39. .Where(s => s.pMainID = pMainID)
  40. .Select(s => new
  41. {
  42. Section = s,
  43. Proeprties = db.PartProperties.Where(p => p.pSecID = partSec.ID)
  44. });
  45.  
  46. <h1>@ViewBag.Part.Name</h1>
  47. <p>@ViewBag.Part.Desc</p>
  48.  
  49. @foreach(var section in ViewBag.Sections)
  50. {
  51. <h2>@section.Section.Name</h2>
  52. <p>@section.Section.Desc</p>
  53.  
  54. <dl>
  55. @foreach(var property in section.Properties)
  56. {
  57. <dt>@property.Name</dt>
  58. <dd>@property.Desc</dd>
  59. }
  60. </dl>
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement