Domanda


Sto cercando un metodo per recuperare l'attributo dell'entità personalizzata senza generare tipi di legame precoce con CRMSVCUTIL.

C'è qualche soluzione per il mio problema?

È stato utile?

Soluzione

Non è necessario generare tipi limitati precoci per recuperare i dati di entità da CRM. Puoi lavorare con un tipo chiamato entità (che è simile alla dinamicenzie di CRM4).

L'SDK ha alcuni esempi su come lavorare con entità in ritardo qui.

Questa classe di entità non è fortemente digitata (a differenza delle entità iniziali generate da CRMSVCUTIL), quindi devi eseguire cast da solo. C'è un metodo sull'entità che aiuterà in questo. Il seguente codice potrebbe darti un'idea di come recuperare un'entità in ritardo.

IOrganizationService service = GetOrganizationService();
var entity = service.Retrieve(entityName,
                                entityId,
                                new ColumnSet(new[]
                                                {
                                                    stringAttributeName,
                                                    intAttributeName,
                                                    floatAttributeName,
                                                    boolAttributeName,
                                                    optionSetAttributeName,
                                                    entityReferenceAttributeName,
                                                }));
var stringValue = entity.GetAttributeValue<string>(stringAttributeName);
var intValue = entity.GetAttributeValue<int?>(intAttributeName);
var floatValue = entity.GetAttributeValue<double?>(floatAttributeName);
var boolValue = entity.GetAttributeValue<bool?>(boolAttributeName);
var optionSetValue = entity.GetAttributeValue<OptionSetValue>(optionSetAttributeName);
var entityReferenceValue = entity.GetAttributeValue<EntityReference>(entityReferenceAttributeName);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top