Wednesday, February 18, 2009

Create Dynamic Entity Record Example


StringProperty firstname = new StringProperty();
firstname.Name = "firstname";
firstname.Value = "Ranjit"; 

StringProperty lastname = new StringProperty();
lastname.Name = "lastname";
lastname.Value = "Singh"; 

// Create the DynamicEntity object.
DynamicEntity contactEntity = new DynamicEntity(); 

// Set the name of the entity type.
contactEntity.Name = EntityName.contact.ToString(); 

// Set the properties of the contact.
contactEntity.Properties = new Property[] {firstname, lastname}; 

// Create the target.
TargetCreateDynamic targetCreate = new TargetCreateDynamic();
targetCreate.Entity = contactEntity; 

// Create the request object.
CreateRequest create = new CreateRequest(); 

// Set the properties of the request object.
create.Target = targetCreate; 

// Execute the request.
CreateResponse created = (CreateResponse) service.Execute(create);

No comments: