到目前为止,这是我的代码,我试图检索 kez_customparamvalue 的 nvarchar 字符串值。通常对于小数或浮点 id 使用类似 CrmDecimalProperty hoursAsCrmNumber = hours as 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();
}
}