you can connect to CRM like this:
put this in your app-config to the "connectionStrings"-Tag:
<add name="MyAppConfigString" connectionString="Url=http://myserver:5555/myorg;Domain=mydomain; Username=myuser; Password=mypassword"/>
this is how to add a contact to CRM 2011/2013
var connection = new CrmConnection("MyAppConfigString");
using (var service = new OrganizationService(connection))
using (var context = new OrganizationServiceContext(service))
{
var contactRecord = new Entity("contact");
contactRecord.Attributes.Add("firstname", "Peter");
contactRecord.Attributes.Add("lastname", "Jackson");
context.AddObject(contactRecord);
context.SaveChanges();
}
to delete a record, simple use this:
service.Delete("contact", myRecordId);
to retrieve a record you could use linq:
var query = context.CreateQuery("contact");
var result = query.FirstOrDefault(r => ((string) r["lastname"]) == "Jackson");
if(result != null)
{
var recordId = result.Id;
}