티스토리 뷰

🌈 .NET MVC

DataTable 관련 메소드 및 속성

James Wetzel 2023. 1. 12. 15:39
728x90
반응형
DataTable filteredDT = dt.Clone();
                
try
{
    var queryGroupByPacking = (
    from virtualTable in dt.AsEnumerable()
    group virtualTable by new
    {
        packing_no = virtualTable.Field<string>("packing_no")
    } into newTable
    select new
    {
        packing_no = newTable.Key.packing_no
    }).Take(parcel_count);

    foreach (var packing in queryGroupByPacking)
    {
        foreach (var item in dt.Select(string.Format("{0} = '{1}'", "packing_no", packing.packing_no)))
        {
            filteredDT.ImportRow(item);
        }
    }
} catch(Exception) {
    filteredDT = new DataTable();
    filteredDT = dt;
}
728x90
반응형