我正在尝试从我的 C# 代码更新发票字段“freightamount”。我能够像字符串和 Guid 一样更新其他字段,但是对于 Money,我在创建或更新发票实体时收到此错误:
There was an error while trying to serialize parameter
http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException
message was 'Type 'Microsoft.Xrm.Sdk.Money' with data contract name
'Money:http://schemas.microsoft.com/xrm/2011/Contracts' is not expected. Consider using a
DataContractResolver or add any types not known statically to the list of known types -
for example, by using the KnownTypeAttribute attribute or by adding them to the list of
known types passed to DataContractSerializer.'. Please see InnerException for more
details.
这是我的代码的一部分:
我使用对“ Microsoft.Xrm.Sdk
”的引用
然后在代码中:
invoice.Attributes.Add(new KeyValuePair<string, object>("freightamount", new Microsoft.Xrm.Sdk.Money (row.amount)));
哪里row.amount
是十进制值。