Update
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace ConsoleApp2.Entities;
|
||||
using System.Text;
|
||||
|
||||
namespace ConsoleApp2.Entities;
|
||||
|
||||
public class DataRecord
|
||||
{
|
||||
@@ -27,16 +29,18 @@ public class DataRecord
|
||||
|
||||
public string[] Fields { get; }
|
||||
|
||||
public string[]? Headers { get; }
|
||||
public string[] Headers { get; }
|
||||
|
||||
public string TableName { get; }
|
||||
|
||||
public string? Database { get; set; }
|
||||
|
||||
public DataRecord(string[] fields, string tableName, string[]? headers = null)
|
||||
|
||||
public DataRecord(string[] fields, string tableName, string[] headers)
|
||||
{
|
||||
if (headers is not null && fields.Length != headers.Length)
|
||||
if (fields.Length != headers.Length)
|
||||
throw new ArgumentException(
|
||||
$"The number of fields does not match the number of headers. Expected: {fields.Length} Got: {headers.Length}",
|
||||
$"The number of fields does not match the number of headers. Expected: {headers.Length} Got: {fields.Length} Fields: {string.Join(',', fields)}",
|
||||
nameof(fields));
|
||||
|
||||
Fields = fields;
|
||||
@@ -44,7 +48,11 @@ public class DataRecord
|
||||
Headers = headers;
|
||||
}
|
||||
|
||||
public string this[int index] => Fields[index];
|
||||
public string this[int index]
|
||||
{
|
||||
get => Fields[index];
|
||||
set => Fields[index] = value;
|
||||
}
|
||||
|
||||
public string this[string columnName] => GetField(this, columnName);
|
||||
|
||||
|
Reference in New Issue
Block a user