...
Create a new lead
Code Block | ||
---|---|---|
| ||
var session = serviceFactory.GetSessionFromConnectionString("MyDynamicsInstance"); // Field values are set with Dictionary<string, object>. var fieldValues = new Dictionary<string, object> { { "firstname", "John" }, { "lastname", "Smith" }, { "emailaddress1", "example@example.com" } }; var lead = await GenericEntity.InsertAsync(session, "lead", fieldValues); |
...
Code Block | ||
---|---|---|
| ||
var session = serviceFactory.GetSessionFromConnectionString("MyDynamicsInstance"); // Find a lead by email address. var lead = await GenericEntity.LoadSingleAsync(session, "lead", (query, xexp) => { query.Filter("emailaddress1 eq 'example@example.com'").Select("firstname, lastname"); } ); // Returned objects support Dictionary syntax to access fields. Console.WriteLine($"First name: {lead["firstname"]}, Last name: {lead["lastname"]}"); |
Update an existing lead
Code Block | ||
---|---|---|
| ||
// Change a field value on a previously loaded lead. lead["lastname"] = "Jones"; await lead.UpdateAsync(session); |