2

课程:

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 类型。

将不胜感激任何建议。现在已经花了一个完整的工作日,没有任何进展。

干杯

4

1 回答 1

2

构建一个CalculateDiscountsFeesItems 列表,然后将该列表分配给CalculateDiscountsFeessItems属性的实例,如下所示:

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属性,如下所示:

fees.Items = listOfCalculateDiscountFeesItem.AsEnumerable()
于 2013-11-27T03:58:07.410 回答