Tuesday, January 21, 2014

LINQ on Datatable Find where all rows are empty ans remove asp.net

Just move the NOT (!) out one level. You want the items where "all rows are null" is not true, rather than where "all of the rows are not null" is true.
DataTable filteredRows = dt.Rows.Cast<DataRow>()
    .Where(row => !row.ItemArray.All(field => field is System.DBNull))
    .CopyToDataTable();

No comments:

Post a Comment

📱Build WhatsApp Bot using .NET + OpenAI

   In this article, you will learn how to build a real-world WhatsApp chatbot using ASP.NET Core and OpenAI. This bot can automatically repl...