**IDataPacker.**GetDataTable([NotNull]this IDataPacker dataPacker,[NotNull]string key) Method
.NET Standard 2.x
Gets the DataTable
object created by the specified element.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public static DataTable GetDataTable(
[NotNull]this IDataPacker dataPacker,
[NotNull]string key)
Parameters
key
System.String
The key specifying which element will be used to create the DataTable
object.
Returns
System.Data.DataTable
Returns the newly created DataTable
object.
Examples
The following code example gets the DataTable
object in IDataPacker
object according to the key.
using SnapObjects.Data;
using System;
using System.Data;
namespace Appeon.ApiDoc.IDataPackerExamples
{
public class GetDataTableExample
{
private readonly SchoolContext _context;
public GetDataTableExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
}
public void Example1(IDataPacker dataPacker)
{
// Gets the DataTable object according to the key value
var table = dataPacker.GetDataTable("student");
// Shows the students.
foreach (DataRow row in table.Rows)
{
Console.WriteLine("First Name: {0}",
row["FirstName"]);
Console.WriteLine("Last Name: {0}",
row["LastName"]);
Console.WriteLine();
}
/* This code example produces the following output:
First Name: Lena
Last Name: Sherwood
First Name: Davies
Last Name: Adam
*/
}
}
}
Applies to
.NET Standard
2.x