检索单个实体';使用c#和asp.net在ms crm4中设置s nvarchar字段
这是我到目前为止的代码,我正在尝试重新保存kez_customparamvalue的nvarchar字符串值。通常,对于十进制或浮点id,使用类似于CrmDecimalProperty HoursacrmNumber=hours的内容作为CrmDecimalProperty;但是我不确定如果是nvarchar该怎么办检索单个实体';使用c#和asp.net在ms crm4中设置s nvarchar字段,c#,dynamics-crm-4,nvarchar,C#,Dynamics Crm 4,Nvarchar,这是我到目前为止的代码,我正在尝试重新保存kez_customparamvalue的nvarchar字符串值。通常,对于十进制或浮点id,使用类似于CrmDecimalProperty HoursacrmNumber=hours的内容作为CrmDecimalProperty;但是我不确定如果是nvarchar该怎么办 public string Retrieve_SC_Target_Rate() { try { // Creat
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();
}
}
我必须使用StringProperty返回正确的值,希望这有帮助
if (paramValue != null)
{
// reutrn the nvarchar value of paramValue
StringProperty stringParamValue = paramValue as StringProperty;
return stringParamValue.Value;
}