Did you know you can LINQ over DataSets too? Well it’s pretty easy. So if you are doing something like this:
foreach (DataRow row in dt.Rows)
{
if (tempEvent.JobHandlerConfig.LicenseKey.Value.Equals(
int.Parse(row[0].ToString())))
{
valid = true;
break;
}
}
You can instead do this with LINQ:
valid = dt.AsEnumerable().Where(p => p.Field<int>(0). Equals(tempEvent.JobHandlerConfig.LicenseKey.Value)).Count() > 0;
Tip By: David McCarter
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
