我在让主详细信息记录与泛型一起使用时遇到问题。我的代码如下
// Setup file engine with Master/Detail types
MasterDetailEngine<PurchaseOrderHeader, PurchaseOrderLine> engine = new MasterDetailEngine<PurchaseOrderHeader, PurchaseOrderLine>(CommonSelector.MasterIfBegins, "H");
// Init the Master/Detail
MasterDetails<PurchaseOrderHeader, PurchaseOrderLine> poRecs = new MasterDetails<PurchaseOrderHeader, PurchaseOrderLine>();
// Setup list for detail lines & populate with test data
List<PurchaseOrderLine> poLines = new List<PurchaseOrderLine>();
for (int i = 1; i <= 5; i++)
{
poLines.Add(new PurchaseOrderLine() { LineMarker = "L", LineNumber = i, ItemCode = "TestCode", Price = 12.34M, Quantity = i * 2, UOM = "EA" });
}
// Attach records to Master/Detail
poRecs.Master = new PurchaseOrderHeader() { LineMarker = "H", PayloadID = "3223232@ariba.acme.com", CustomerPO = "DO1234", ShipToAddressCode = "ShipToAddressCode", BillToAddressCode = "BillToAddressCode" };
poRecs.Details = poLines.ToArray();
// Write file
engine.WriteFile("SampleFile.txt", poRecs);
我收到以下编译错误:
CS1502:最好的重载方法匹配
FileHelpers.MasterDetail.MasterDetailEngine<ImportExport.PurchaseOrderHeader,ImportExport.PurchaseOrderLine>.WriteFile(string,System.Collections.Generic.IEnumerable<FileHelpers.MasterDetail.MasterDetails<ImportExport.PurchaseOrderHeader,ImportExport.PurchaseOrderLine>>)
有一些无效的论点。
我尝试过投射poRecs
,IEnumerable
但仍然无法正常工作。
任何建议将不胜感激!