我正在尝试在发票行项目上设置TrackingCategory的值。我的代码如下:
Authorization
它在 LineItem li = new LineItem();
li.LineAmount = inv.LineItems[i].LineAmount;
li.ItemCode = inv.LineItems[i].ItemCode;
li.Description = inv.LineItems[i].Description;
li.AccountCode = inv.LineItems[i].AccountCode;
li.UnitAmount = inv.LineItems[i].UnitAmount;
var categories = inv.Categories.Where(c => c.TicketChargeLineId == inv.LineItems[i].TicketChargeLineId);
foreach(var c in categories)
{
if(c.Value != "")
{
ItemTrackingCategory tc = new ItemTrackingCategory();
tc.Name = c.Name;
tc.Id = c.Id;
tc.Option = c.Value;
li.Tracking.Add(tc);
}
}
lineItems.Add(li);
处出错。它给出错误“对象引用未设置为对象的实例。”,但是tc不为空。它的确为OptionId显示了一个空的Guid。非常感谢您的协助。