我想看一个使用FileHelpers编写MasterDetail文件的简单示例。
我理解如何阅读MasterDetail文件,但是,我找不到创建一个文件的示例。
答案 0 :(得分:2)
我能够以这种方式完成它。我不确定你为什么要投票,因为没有任何例子说明写作。
max-height: 100%;
height: 100%;
width: auto;
答案 1 :(得分:0)
我正在将伪数据添加到John Doe的代码中,以便快速进行测试
var headerData =
new Customers
{
Address = "address",
City = "City",
CompanyName = "CompanyName",
ContactName = "ContactName",
ContactTitle = "ContactTitle",
Country = "Country",
CustomerID = "CustomerID"
};
var listDetail =
new Orders[]
{
new Orders
{
CustomerID = "CustomerID",
EmployeeID = 1,
Freight = 1.03M,
OrderDate = DateTime.Now,
OrderID = 1234,
RequiredDate = DateTime.Now.AddDays(2),
ShippedDate = DateTime.Now.AddDays(-2),
ShipVia = 1
},
new Orders
{
CustomerID = "CustomerID",
EmployeeID = 1,
Freight = 4.57M,
OrderDate = DateTime.Now,
OrderID = 5678,
RequiredDate = DateTime.Now.AddDays(2),
ShippedDate = DateTime.Now.AddDays(-2),
ShipVia = 1
}
};
var engine = new MasterDetailEngine<Customers, Orders>();
var listMasterDetail = new List<MasterDetails<Customers, Orders>>();
var a = new MasterDetails<Customers, Orders>
{
Master = headerData,
Details = listDetail.ToArray()
};
listMasterDetail.Add(a);
engine.WriteFile(@"C:/temp/MyFile.txt", listMasterDetail);