public static Guid CreateEntity(Entity entity, CrmConnection connection = null) { using (CrmOrganizationServiceContext service = new CrmOrganizationServiceContext(connection ?? XrmConnection.Connection)) { Guid id = service.Create(entity); entity.Id = id; return(id); } }
private static Guid CreateImportEntity(CrmOrganizationServiceContext serviceContext, string sourceEntityName) { var import = new Import { Name = "Import of " + sourceEntityName, ModeCode = new OptionSetValue(0) }; return(serviceContext.Create(import)); }
public Guid CreateAccount(string name) { var entity = new Entity("account") { Attributes = new Microsoft.Xrm.Sdk.AttributeCollection { { "name", name } } }; var id = _crmContext.Create(entity); return(id); }
private void CreateImportFileEntity(CrmOrganizationServiceContext serviceContext, string content, Guid importId, Guid dataMapId) { var importFile = new ImportFile { Name = Path.GetFileName(this.FilePath), Source = this.FilePath, Content = content, SourceEntityName = this.SourceEntityName, TargetEntityName = this.TargetEntityName, FileTypeCode = new OptionSetValue(0), DataDelimiterCode = new OptionSetValue(1), FieldDelimiterCode = new OptionSetValue(2), IsFirstRowHeader = new bool?(true), EnableDuplicateDetection = new bool?(false), ProcessCode = new OptionSetValue(1), ImportId = new EntityReference("import", importId), ImportMapId = new EntityReference("importmap", dataMapId) }; serviceContext.Create(importFile); }
private static Guid CreateImportEntity(CrmOrganizationServiceContext serviceContext, string sourceEntityName) { var import = new Import { Name = "Import of " + sourceEntityName, ModeCode = new OptionSetValue(0) }; return serviceContext.Create(import); }