DataStoreDataExtensions.ExportString(this IDataStoreBase dataStore, bool colheading = true) Method
.NET Standard 2.x
Exports all of the data rows from the primary buffer of the DataStore to a string. The column name is exported by default.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public static int ImportString(this IDataStoreBase dataStore, bool colheading = true);
Parameters
colheading
System.Boolean
True
(default): The column name is exported.
False
: The column name is not exported.
Returns
System.String
Returns the string if it succeeds.
Remarks
Values are separated by tabs. A newline character ("\r\n" for non-Unix platforms and "\n" for Unix platforms) is placed at the end of each line.
Examples
The following code example demonstrates how to use the ExportString
method to export the department records (with or without column heading) from the primary buffer to a string.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.DataStoreDataExtensionsExamples
{
public class ExportStringExample
{
private readonly SchoolContext _context;
public ExportStringExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example1()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
// Generates data in the primary/delete/filter buffers for this example.
datastore.Retrieve();
datastore.DeleteRow(0);
datastore.SetFilter("departmentid < 5");
datastore.Filter();
// datastore.ExportString() equals to datastore.ExportString(true)
string text = datastore.ExportString();
Console.WriteLine("datastore.ExportString():");
Console.WriteLine(text);
text = datastore.ExportString(false);
Console.WriteLine("datastore.ExportString(false):");
Console.WriteLine(text);
/*This code produces the following output:
datastore.ExportString():
"Departmentid" "Name" "Budget" "Startdate" "Administrator"
2 "English" 120000.0000 9/1/2007 12:00:00 AM 6
4 "Economics" 200000.0000 9/1/2007 12:00:00 AM 4
datastore.ExportString(false):
2 "English" 120000.0000 9/1/2007 12:00:00 AM 6
4 "Economics" 200000.0000 9/1/2007 12:00:00 AM 4
*/
}
}
}
Example Refer To
DataWindow File: d_department
Applies to
.NET Standard
2.x