Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (chemexist == false) // conditionally creating WtrChem record
- {
- WtrChem wc = new WtrChem();
- wc.Contact = "John Smith";
- ..
- wc.Phone = ("800-888-9988");
- Db.WtrChem.Add(wc);
- Db.SaveChanges();
- }
- WtrChemDetail psw = new WtrChemDetail (); // creating details record for WtrChem
- psw.Comments = comment;
- ..
- ..
- Db.WtrChemDetail.Add(psw);
- Db.SaveChanges();
- // Get the item. Include makes sure that you get the referenced detail as well.
- WtrChem wc = Db.WtrChem.Include(x => x.Detail).SingleOrDefault();
- if (wc == null) // creating WtrChem record
- {
- // If it wasn't found, create and add
- wc = new WtrChem();
- Db.WtrChem.Add(wc);
- }
- wc.Contact = "John Smith";
- ..
- wc.Phone = ("800-888-9988");
- // Deal with the
- WtrChemDetail psw = new WtrChemDetail (); // creating details record for WtrChem
- psw.Comments = comment;
- wc.Detail = psw;
- Db.SaveChanges();
- using System.Data.Entity;
Add Comment
Please, Sign In to add comment