これはこれまでの私のコードで、kez_customparamvalue の nvarchar 文字列値を取得しようとしています。通常、10 進数または浮動小数点 ID には、CrmDecimalProperty のように使用します。しかし、nvarchar の場合はどうすればよいかわかりません。
public string Retrieve_SC_Target_Rate()
{
try
{
// Create the retrieve target.
TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic();
// Set the properties of the target.
targetRetrieve.EntityName = EntityName.kez_custimizationpararmeter.ToString();
targetRetrieve.EntityId = new Guid ("D739150F-F68B-E211-AD2B-00155D011F06");
// Create the request object.
RetrieveRequest retrieve = new RetrieveRequest();
// Set the properties of the request object.
retrieve.Target = targetRetrieve;
// Create the column set object that indicates the properties to be retrieved.
ColumnSet cols = new ColumnSet();
cols.Attributes = new string[] { "kez_customparamvalue" };
// Set the properties of the column set.
retrieve.ColumnSet = cols;
// Indicate that the BusinessEntity should be retrieved as a DynamicEntity.
retrieve.ReturnDynamicEntities = true;
// Execute the request.
RetrieveResponse retrieved = (RetrieveResponse)svc.Execute(retrieve);
// Extract the DynamicEntity from the request.
DynamicEntity entity = (DynamicEntity)retrieved.BusinessEntity;
Property paramValue = entity.Properties.Where(p => p.Name == "kez_customparamvalue").FirstOrDefault();
if (paramValue != null)
{
// reutrn the nvarchar value of paramValue
}
return "The value is "; // + param value
}
catch (Exception e)
{
// The variable 'e' can access the exception's information.
return e.StackTrace.ToString();
}
}