Thursday 11 September 2014

Negative Value Condition in C# linq

Negative Value Condition
////////
var results = (from row in tb1.AsEnumerable()
               where row.Field<double>("ColumnNameHere").<0)
               select row).Count();
            OR  var results = (from row in DataSetInstance.Table[0].AsEnumerable()
               where row.Field<double>("Order_num").ToString().Contains("-")
               select row).Count();  
if( results == 0 )
{
    // Do the processing
}
else
{
    //Negative value not allow.
}
/////////

No comments:

Post a Comment