类:
public class CalculateDiscountsFees
{
public IEnumerable<CalculateDiscountsFeesItem> Items { get; set; }
}
public class CalculateDiscountsFeesItem
{
public int RequestID { get; set; }
public CalculateDiscountsFeesSale Sale { get; set; }
public DateTime PaymentDate { get; set; }
}
public class CalculateDiscountsFeesSale
{
public Guid UID { get; set; }
public CalculateDiscountsFeesSaleType Type { get; set; }
}
这些是我需要使用的sdk中的类。我需要构建CalculateDiscountsFees然后将其传递回sdk。但是我这样做有困难。我想这样做的方法是循环,创建一个CalculateDiscountsFeesItem,然后尝试将其添加到CalculateDiscountsFees。这不起作用,因为ienumerable没有添加。
我已经尝试创建扩展模块来创建我自己的添加但未能使其工作。
以下是我想在理想世界中工作的代码。希望这会让你对我想要做的事情有所了解。
Dim fees As New CalculateDiscountsFees
Dim sale = New CalculateDiscountsFeesSale
Dim feesitem = New CalculateDiscountsFeesItem
Dim id = List.Item(0).UID
sale.UID = id
sale.Type = Version2.Sale.CalculateDiscountsFeesSaleType.Invoice
feesitem.RequestID = 1
feesitem.PaymentDate = Now()
feesitem.Sale = sale
fees.Items.Add( feesitem)
Dim feeResult = CalculateDiscountsFeesSvc.Execute(companyFile, fees, credentials)
想知道如何构建CalculateDiscountFees。我已经尝试创建一个CalculateDiscountFeesItems列表,但是我无法将其转换为CalculateDiscountFees类型。
不胜感激任何建议。现在已经花了整整一个工作日没有任何进展。
干杯
答案 0 :(得分:2)
构建CalculateDiscountsFeesItem
的列表,然后获取该列表并将其分配给CalculateDiscountsFees
的{{1}}属性的实例,如下所示:
Items
现在,您可以带上Dim fees As New CalculateDiscountsFees
Dim listOfCalculateDiscountsFeesItem As New List(Of CalculateDiscountsFeesItem)
Dim sale As New CalculateDiscountsFeesSale()
Dim id = List.Item(0).UID
sale.UID = id
sale.Type = Version2.Sale.CalculateDiscountsFeesSaleType.Invoice
Dim feesItem As New CalculateDiscountsFeesItem()
feesitem.RequestID = 1
feesitem.PaymentDate = Now()
feesitem.Sale = sale
listOfCalculateDiscountFeesItem.Add(feesItem)
...
Repeat above for as many fees items as you need in the list
...
并将其分配到List(Of CalculateDiscountsFeesItem)
属性,如下所示:
fees.Items