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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s