IDataApiDumpToCsv Method

Enumerate a Data Source and dump the whole result set to a CSV file in the system temp folder. The file is encoded as UTF-8 (with BOM), starts with a header row and every value is safely escaped following RFC 4180. This streams the data, so it is suitable for exporting extensive collections without loading them all into memory.

Definition

Namespace: Casewhere.Runtime.DSL.Api
Assembly: Casewhere.Runtime (in Casewhere.Runtime.dll) Version: 2.9.8.6
C#
string DumpToCsv(
	DataSourceEnumerationQuery query
)

Parameters

query  DataSourceEnumerationQuery
An instance of the DataSourceEnumerationQuery type. When ProjectedFields are specified, they define the CSV columns and their order; otherwise the columns are taken from the fields of the first enumerated object. The Instances of DataSourceEnumerationQuery can't create directly. It is just create from static method DataSourceEnumerationQuery.For("dataSourceName").

Return Value

String
The full path of the generated CSV file in the temp folder.

Example

C#
                    var dataApi = ctx.Use<IDataApi>();
var filter = FilterBuilder.Create().Eq("Active", true).Build();
var query = DataSourceEnumerationQuery.For("EmployeeWithCompany")
    .FilterBy(filter)
    .ProjectOn("Name", "Company");

var csvPath = dataApi.DumpToCsv(query);
Log.Info("CSV exported to {path}", csvPath);
                  

See Also