Guest User

Untitled

a guest
Aug 15th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. How to write Linq-To-SQL statment which is equal to my following TSQL?
  2. Update table1
  3. Set Name = 'John',
  4. Address = null
  5. where
  6. ID = 1
  7.  
  8. var tab = db.Table1.Single(s => s.ID == 3);
  9. tab.Name = DateTime.Now;
  10. tab.Address = null;
  11. db.SubmitChanges();
  12.  
  13. using (var dataContext = new MyEntities())
  14. {
  15. var contact = Contacts.Single (c => c.ContactID == 1);
  16. contact.FirstName = 'John';
  17. contact.Address= 'Toronto';
  18. dataContext.SaveChanges();
  19. }
  20.  
  21. var entity = context.Table1.Single(t => t.Id == 1);
  22.  
  23. entity.Name = "John";
  24. entity.Address = "Toronto";
  25.  
  26. context.SubmitChanges();
Add Comment
Please, Sign In to add comment