Guest User

Untitled

a guest
Jan 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. if (chemexist == false) // conditionally creating WtrChem record
  2. {
  3. WtrChem wc = new WtrChem();
  4. wc.Contact = "John Smith";
  5. ..
  6. wc.Phone = ("800-888-9988");
  7. Db.WtrChem.Add(wc);
  8. Db.SaveChanges();
  9. }
  10.  
  11.  
  12. WtrChemDetail psw = new WtrChemDetail (); // creating details record for WtrChem
  13. psw.Comments = comment;
  14. ..
  15. ..
  16. Db.WtrChemDetail.Add(psw);
  17. Db.SaveChanges();
  18.  
  19. // Get the item. Include makes sure that you get the referenced detail as well.
  20. WtrChem wc = Db.WtrChem.Include(x => x.Detail).SingleOrDefault();
  21.  
  22. if (wc == null) // creating WtrChem record
  23. {
  24. // If it wasn't found, create and add
  25. wc = new WtrChem();
  26. Db.WtrChem.Add(wc);
  27. }
  28.  
  29. wc.Contact = "John Smith";
  30. ..
  31. wc.Phone = ("800-888-9988");
  32.  
  33. // Deal with the
  34. WtrChemDetail psw = new WtrChemDetail (); // creating details record for WtrChem
  35. psw.Comments = comment;
  36. wc.Detail = psw;
  37.  
  38. Db.SaveChanges();
  39.  
  40. using System.Data.Entity;
Add Comment
Please, Sign In to add comment