リストに変換したいDataTableがあります
var rows = cableDataTable.AsEnumerable()
.Select((x) =>
new
{
TagGroup = x.Field<string>("TagNo"),
RowNo = (i == 0) ? (j++).ToString() : "",
TagNo = x.Field<string>("TagNo"),
FromBayPanel = x.Field<string>("FromBayPanel"),
Size = x.Field<string>("CoreSize"),
Type = x.Field<string>("Type"),
FromBay = x.Field<string>("FromBay"),
FromPanel = x.Field<string>("FromPanel"),
CoreNo = x.Field<string>("CoreNo") == DBNull.Value.ToString() ? "" : x.Field<string>("CoreNo"),
RealCoreNo = x.Field<int>("RealCoreNo"),
FromDevice = x.Field<string>("FromDevice") == DBNull.Value.ToString() ? "" : x.Field<string>("FromDevice"),
FromTerminal = x.Field<string>("FromTerminal") == DBNull.Value.ToString() ? "" : x.Field<string>("FromTerminal"),
FromRef = x.Field<string>("FromRef") == DBNull.Value.ToString() ? "" : x.Field<string>("FromRef"),
ToBay = x.Field<string>("ToBay"),
ToPanel = x.Field<string>("ToPanel"),
ToDevice = x.Field<string>("ToDevice") == DBNull.Value.ToString() ? "" : x.Field<string>("ToDevice"),
ToTerminal = x.Field<string>("ToTerminal") == DBNull.Value.ToString() ? "" : x.Field<string>("ToTerminal"),
ToRef = x.Field<string>("ToRef") == DBNull.Value.ToString() ? "" : x.Field<string>("ToRef"),
Remark = x.Field<string>("Remark") == DBNull.Value.ToString() ? "" : x.Field<string>("Remark"),
}).ToList();
複数の列で DataTable をグループ化する必要があります。しかし、私がこれを好きなとき
1) どうすればそれができますか?
2) もう 1 つの質問は、DBNull 値を SQL Server 側 (isNull コマンド) で変換するか、クライアント側で変換する方が良いですか?