This commit is contained in:
2023-12-29 16:16:05 +08:00
parent 6b88f5bd40
commit c53d2927bb
24 changed files with 909 additions and 386 deletions

View File

@@ -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);