DimerceDemoApplication/services/CsvWriter.cs

22 lines
634 B
C#
Raw Normal View History

using System.Globalization;
using CsvHelper;
class CsvFileWriter
{
private TextWriter textWriter;
private CsvWriter csvWriter;
public CsvFileWriter(FileInfo fileInfo) {
textWriter = new StreamWriter(fileInfo.FullName);
csvWriter = new CsvWriter(textWriter, CultureInfo.InvariantCulture);
}
public void writeOutRow(OrderModel orderModel) {
csvWriter.WriteField(orderModel.OrderId);
csvWriter.WriteField(orderModel.OrderDescription);
csvWriter.WriteField(orderModel.CustomerId);
csvWriter.WriteField(orderModel.TotalPrice);
csvWriter.NextRecord();
}
}