Let's say I have a class TmpClass, I use this class for returning data from Excel sheet using LinqToExcel ExcelQueryFactory. In this class I need to implement some logic to check data correctness. When I retrieve data from Excel sheet using ExcelQueryFactory it returns ExcelQueryable (which descends from IQueryalbe) There can be validation problems with multiple TmpClass instances - how can I process them in a collections style?
Class for Excel sheet data mapping
public class TmpClass
{
private string _name;
public string Name
{
set {
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("Value can not be null/whitespace!");
}
_name = value;
}
}
}
retrieving data from Excel sheet with LinqToExcel ExcelQueryFactory
..initialize ExcelQueryFactory instance, get column names, set column mapping
//retrieve data
var dataFromExcel = excel.Worksheet<TmpClass>(...worksheet name).ToList();
When reading Excel sheet rows, for some of them TmpClass.Name setter function will throw ArgumentException - I need a way to process all the Excel sheet rows:
- do some actions for rows (logging) that had ArgumentException
- and do some other operations for rows with valid data.
Can I get a collection of invalid items (with exception info perhaps)? Can I get a collection of valid items?