C# – Creating a New Instance of Entity and Persisting to the Database

var customer = new Customer();

//Populate properties of customer
dbCustomers.Add(customer);
dbCustomers.SaveChanges();

Filtering DbSets  using LINQ method syntax:

ACMEEntities db = new ACMEEntities();
var dbCustomers = dbCustomers.OrderBy(p => p.Name).ToList();

Lambda expression – “mini methods”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.