There have been numerous requests on other blogs about sample code to on how to create entities in CRM. One way is to use the CRM web service to create business entities, however by doing so, you're only limited to out-of-the-box entities with system attributes. To retrieve anything more "dynamic," you'll have to employ other methods. Please remember that in order to create any record, you must have the proper permissions on that entity.
Below is a code example of how to create a record using dynamic entities:
public void CreateEntity(ICrmService service)
{
//variable initialization
DynamicEntity entity = new DynamicEntity(); //target entity to update
TargetCreateDynamic targetCreate = new TargetCreateDynamic(); //used to update entity
CreateRequest createRequest = new CreateRequest(); //request to create entity
entity.Name = <entity name>
//add the properties
entity.Properties.Add(<property>);
Entity.Properties.Add(<property>);
//set the target to update, and the request to update for
targetCreate.Entity = entity;
createRequest.Target = targetCreate;
//execute the update request
service.Execute(createRequest);
}
Hope this helps, happy coding!