You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
660 B
23 lines
660 B
using System.Data;
|
|
|
|
namespace Infrastructure.Extensions
|
|
{
|
|
public static class DataTableExtensions
|
|
{
|
|
public static DataTable SetHeaders(this DataTable dataTable, params string[] headers)
|
|
{
|
|
foreach (var item in headers)
|
|
{
|
|
dataTable.Columns.Add(new DataColumn(item));
|
|
}
|
|
return dataTable;
|
|
}
|
|
|
|
public static DataTable Add(this DataSet dataSet, string tableName, params string[] headers)
|
|
{
|
|
var dataTable = dataSet.Tables.Add();
|
|
dataTable.TableName = tableName;
|
|
return dataTable.SetHeaders(headers);
|
|
}
|
|
}
|
|
} |