init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
31
Kreta.BusinessLogic/Extensions/DataTableExtensions.cs
Normal file
31
Kreta.BusinessLogic/Extensions/DataTableExtensions.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Kreta.Web.Helpers.Extension
|
||||
{
|
||||
public static class DataTableExtensions
|
||||
{
|
||||
public static void RemoveDataRowIfAnyColumnValueMatch(this DataTable dataTable, string columnName, List<int> columnValues)
|
||||
{
|
||||
if (!dataTable.Columns.Contains(columnName) || (dataTable.Columns[columnName].DataType != typeof(int?) && dataTable.Columns[columnName].DataType != typeof(int)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
{
|
||||
foreach (var columnValue in columnValues)
|
||||
{
|
||||
if (row.RowState != DataRowState.Deleted && row.Field<int?>(columnName) == columnValue)
|
||||
{
|
||||
row.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataTable.AcceptChanges();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue