// This is how to Use the Early Bound Entity Classes for Create, Update, and Delete in CRM 2011
Create a New Entity Record Using the Early-bound Entity Classes and the Organization Service Context
OrganizationServiceContext orgContext =new OrganizationServiceContext(_serviceProxy);
Contact contact = new Contact()
{
FirstName = "xyz",
LastName = "abc",
Address1_Line1 = "1337",
Address1_City = "London",
Address1_StateOrProvince = " South Wales ",
Address1_PostalCode = "000000",
Telephone1 = "44-123-4567"
};
orgContext.AddObject(contact);
orgContext.SaveChanges();
Update a New Entity Record Using the Early-bound Entity Classes and the Organization Service Context
var contact = orgContext .CreateQuery<Contact>().First(c => c.FirstName == "xyz");
contact.JobTitle = "xCRM Hack";
orgContext .UpdateObject(contact);
orgContext .SaveChanges();
Delete a New Entity Record Using the Early-bound Entity Classes and the Organization Service Context
var contact = orgContext .CreateQuery<Contact>().First(c => c.FirstName == "xyz");
orgContext .DeleteObject(contact);
orgContext .SaveChanges();
Create a New Entity Record Using the Early-Bound Entity Classes and without a Context Object
Contact contact = new Contact()
{
FirstName = "xyz",
LastName = "abc",
Address1_Line1 = "1337",
Address1_City = "London",
Address1_StateOrProvince = " South Wales ",
Address1_PostalCode = "000000",
Telephone1 = "44-123-4567"
};
_contactId = _serviceProxy.Create(contact);