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.
 
 

95 lines
2.3 KiB

using System;
using System.Collections.Generic;
namespace Znyc.Cloudcar.Admin.Commons.Data
{
/// <summary>
/// 查询结果数据表样式
/// </summary>
public class MicroDataTable
{
/// <summary>
/// 整个查询语句结果的总条数,而非本DataTable的条数
/// </summary>
public int TotalCount { get; set; }
/// <summary>
/// 数据列名称
/// </summary>
public List<MicroDataColumn> Columns { get; set; } = new();
/// <summary>
/// 数据记录
/// </summary>
public List<MicroDataRow> Rows { get; set; } = new();
/// <summary>
/// 主键
/// </summary>
public MicroDataColumn[] PrimaryKey { get; set; }
public MicroDataRow NewRow()
{
return new(Columns, new object[Columns.Count]);
}
}
public class MicroDataColumn
{
public string ColumnName { get; set; }
public Type ColumnType { get; set; }
}
public class MicroDataRow
{
private readonly object[] _ItemArray;
public MicroDataRow(List<MicroDataColumn> columns, object[] itemArray)
{
Columns = columns;
_ItemArray = itemArray;
}
public List<MicroDataColumn> Columns { get; }
public object this[int index]
{
get => _ItemArray[index];
set => _ItemArray[index] = value;
}
public object this[string columnName]
{
get
{
int i = 0;
foreach (MicroDataColumn column in Columns)
{
if (column.ColumnName == columnName)
{
break;
}
i++;
}
return _ItemArray[i];
}
set
{
int i = 0;
foreach (MicroDataColumn column in Columns)
{
if (column.ColumnName == columnName)
{
break;
}
i++;
}
_ItemArray[i] = value;
}
}
}
}