File Helpers provides an examples on the website.
The code looks like this (based on the linked example)
SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar));
storage.ServerName = "MyServerName";
storage.DatabaseName = "Northwind";
storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder);
The FillRecords
method should look like this
protected void FillRecordOrder(object rec, object[] fields)
{
OrdersVerticalBar record = (OrdersVerticalBar) rec;
record.OrderID = (int) fields[0];
record.CustomerID = (string) fields[1];
record.EmployeeID = (int) fields[2];
record.OrderDate = (DateTime) fields[3];
record.RequiredDate = (DateTime) fields[4];
if (fields[5] != DBNull.Value)
record.ShippedDate = (DateTime) fields[5];
else
record.ShippedDate = DateTime.MinValue;
record.ShipVia = (int) fields[6];
record.Freight = (decimal) fields[7];
}
Then you can run the following to write the content directly to the output file.
FileDataLink.EasyExtractToFile(storage, "outfile.txt");