Advertisement
Guest User

Untitled

a guest
Mar 11th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. namespace EntityFrameword
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. var context = new SoftuniContext();
  8. var newAddress = new Address()
  9. {
  10. AddressText = "Vitoshka 15",
  11. TownID = 4,
  12. };
  13. context.Addresses.Add(newAddress);
  14. var person = context.Employees;
  15. foreach (var per in person.Where(a => a.LastName == "Nakov"))
  16. {
  17. per.AddressID = newAddress.AddressID;
  18. }
  19. context.SaveChanges();
  20. var adresses = context.Addresses;
  21. foreach (var adr in adresses.OrderByDescending(a => a.AddressText))
  22. {
  23. Console.WriteLine(adr);
  24. }
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement