using System.Collections.Generic;
public static void Main()
Sample example = new Sample();
COAClassRecord record = new COAClassRecord { ID = 1, Code = "ABC", Title = "Sample Title" };
DataRow row = example.GetDataRow(record);
Console.WriteLine($"Id: {row["Id"]}, Code: {row["Code"]}, Title: {row["Title"]}");
public List<DataRow> Data { get; set; } = new();
public DataRow GetDataRow(COAClassRecord _Record)
DataRow _DataRow = Data.DefaultIfEmpty(CreateDefaultDataRow()).FirstOrDefault();
_DataRow["Id"] = _Record.ID;
_DataRow["Code"] = _Record.Code;
_DataRow["Title"] = _Record.Title;
private DataRow CreateDefaultDataRow()
DataTable table = new DataTable();
table.Columns.Add("Id", typeof(int));
table.Columns.Add("Code", typeof(string));
table.Columns.Add("Title", typeof(string));
public class COAClassRecord
public int ID { get; set; }
public string Code { get; set; }
public string Title { get; set; }