我有这个OData结构:
{
"@odata.context":"[domain]:7048/NAV/ODataV4/$metadata#Collection(NAV.SalesOrder)","value":[
{
"@odata.etag":"W/\"JzQ0O0pBQUFBQUNMQVFBQUFBSjcvekFBTVFCTkFERUFUZ0JFQUZNQUFBQUFBQT09NzsyMDY5MDI0MDsn\"","Document_Type":"Order","No":"01M1NDS","Sell_to_Customer_Name":"","Quote_No":"","Sell_to_Address":"","Sell_to_Address_2":"","Sell_to_Post_Code":"","Sell_to_City":"","Sell_to_Contact_No":"","Sell_to_Contact":"","No_of_Archived_Versions":0,"Document_Date":"2019-03-20T00:00:00Z","Posting_Date":"2019-03-20T00:00:00Z","Order_Date":"2019-03-20T00:00:00Z","Due_Date":"0001-01-01T00:00:00Z","Requested_Delivery_Date":"0001-01-01T00:00:00Z","Promised_Delivery_Date":"0001-01-01T00:00:00Z","External_Document_No":"","Salesperson_Code":"","Campaign_No":"","Opportunity_No":"","Responsibility_Center":"","Assigned_User_ID":"","Job_Queue_Status":" ","Status":"Open","WorkDescription":"","Currency_Code":"","Prices_Including_VAT":false,"VAT_Bus_Posting_Group":"","Payment_Terms_Code":"","Payment_Method_Code":"","SelectedPayments":"No payment service is made available.","Transaction_Type":"","Shortcut_Dimension_1_Code":"","Shortcut_Dimension_2_Code":"","Payment_Discount_Percent":0,"Pmt_Discount_Date":"0001-01-01T00:00:00Z","Direct_Debit_Mandate_ID":"","ShippingOptions":"Default (Sell-to Address)","Ship_to_Code":"","Ship_to_Name":"","Ship_to_Address":"","Ship_to_Address_2":"","Ship_to_Post_Code":"","Ship_to_City":"","Ship_to_Country_Region_Code":"","Ship_to_Contact":"","Shipment_Method_Code":"","Shipping_Agent_Code":"","Shipping_Agent_Service_Code":"","Package_Tracking_No":"","BillToOptions":"Default (Customer)","Bill_to_Name":"","Bill_to_Address":"","Bill_to_Address_2":"","Bill_to_Post_Code":"","Bill_to_City":"","Bill_to_Contact_No":"","Bill_to_Contact":"","Location_Code":"","Shipment_Date":"2019-03-20T00:00:00Z","Shipping_Advice":"Partial","Outbound_Whse_Handling_Time":"","Shipping_Time":"","Late_Order_Shipping":false,"EU_3_Party_Trade":false,"Transaction_Specification":"","Transport_Method":"","Exit_Point":"","Area":"","Prepayment_Percent":0,"Compress_Prepayment":false,"Prepmt_Payment_Terms_Code":"","Prepayment_Due_Date":"0001-01-01T00:00:00Z","Prepmt_Payment_Discount_Percent":0,"Prepmt_Pmt_Discount_Date":"0001-01-01T00:00:00Z","Date_Filter":"''..03/22/19","ETag":"44;JAAAAACLAQAAAAJ7/zAAMQBNADEATgBEAFMAAAAAAA==7;20690240;"
}
}
,我需要向属性“值”插入新订单。简单检索列表即可:
var orders = await client
.For(Constants.Company).Key(Constants.CompanyName)
.NavigateTo("SalesOrder")
.FindEntriesAsync();
但是将项目添加到新列表不起作用:
var product = await client
.For(Constants.Company).Key(Constants.CompanyName)
.NavigateTo<SalesOrder>("SalesOrder")
.Set(CreateSaleOrder(customerState))
.InsertEntryAsync();
导致此错误:
Microsoft.OData.ODataException:
A property with name 'Document_Type' was found when reading a top-level resource set. No properties other than the resource set property with the name 'value' are allowed.
我也尝试使用.Select和.Expand解决方案,但无济于事。