I have following DataTable (dataTable)
**ColumnName** : **Data**
IDS : System.String
QTY : System.Int32
DOS System.DateTime
and following dictionary
Dictionary dict=new Dictionary();
dict["ID"]=typeof(string);
dict["QTY"]=typeof(Int32);
dict["DOS"]=typeof(DateTime);
Using following method for validating data of dataTable
public void ValidateData(Dictionary dict, DataTable dataTable)
{
foreach (DataRow row in dataTable.Rows)
{
// validate data here
}
}
What is best/efficient way to validate data here.
Thanks.
VulpesPosted Aug 27, 2013, 11:45 AM
If you mean that the 3 columns in each row of the datatable should have the same values as the dictionary, then try this:
public bool ValidateData(Dictionary
{
foreach (DataRow row in dataTable.Rows)
{
if (row["IDS"].ToString() != dict["IDS"].ToString()) return false;
if (row["QTY"].ToString() != dict["QTY"].ToString()) return false;
if (row["DOS"].ToString() != dict["DOS"].ToString()) return false;
}
return true;
}