using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Sdk.Messages;
// Upsert request using early binding //Upsert request using late binding
Account account = new Account(); Entity account = new Entity("account");
account.Name = "Early Binding"; account["name"] = "Late binding";
KeyAttributeCollection acckeys = new KeyAttributeCollection();
acckeys.Add("accountnumber", "012345");
account.KeyAttributes = acckeys;
UpsertRequest upsertRequest = new UpsertRequest()
{
Target = account,
};
UpsertResponse response = (UpsertResponse)_orgService.Execute(upsertRequest);
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Sdk.Messages;
// Upsert request using early binding //Upsert request using late binding
Account account = new Account(); Entity account = new Entity("account");
account.Name = "Early Binding"; account["name"] = "Late binding";
KeyAttributeCollection acckeys = new KeyAttributeCollection();
acckeys.Add("accountnumber", "012345");
account.KeyAttributes = acckeys;
UpsertRequest upsertRequest = new UpsertRequest()
{
Target = account,
};
UpsertResponse response = (UpsertResponse)_orgService.Execute(upsertRequest);
if (response.RecordCreated)
Console.WriteLine("Record Created in
CRM");
else
Console.WriteLine("Record Updated in
CRM");