I'm reading input from two excel worksheets (using Linq-To-Excel
) into two lists. One of the worksheets has an unwanted column of data (column name is known). The other columns in both worksheets however contain exactly the same type of data.
First part of my question is:
How can I exclude only that unwamted column of data in the select statement (without having to write select.column names for the other 25 or so columns? I intend to do this for the below purposes:
- Make both the lists of the same type
- Merge the two lists
Possibly move this block of code to a call procedure, as eventually I'll have to read from many more worksheets
ExcelQueryFactory excel = new ExcelQueryFactory(FilePath); List<STC> stResults = (from s in excel.Worksheet<STC>("StaticResults") select s) .ToList(); List<DYN> dynResults = (from s in excel.Worksheet<DYN>("DynamicResults") select s) //how can I EXCLUDE just one of the columns here?? .ToList();
I'm new to c# and linq. So please pardon my ignorance :-)
The second part of my question is:
The above data that I'm extracting is a bit on the fat side (varying from 100,000 to 300,000 rows). I have to keep giving repeated linq queries on the lists above (in the range of 1000 to 4000 times) using a for loop. Is there a better way to implement this, as its taking a huge toll on the performance.
EDIT_1:
Regarding the input files:
- StaticResults file has 28 Columns (STC Class has 28 properties)
- DynamicResults file has 29 Columns (28 columns with the same properties/column names as static plus one additional property, which is not required) (DYN is a derived class from STC)