I have method which accepts IQueryable<T>
as a parameter called attachments
. Inside this method I filter the query further in multiple if
statements. So my code is as follows:
if(firstCondition)
{
attachments = attachments.Where(i => i.TestItemId == 1); //3 records in db
DoWork(attachments);
}
if(secondCondition)
{
attachments = attachments.Where(i => i.TestItemId == 2); //2 records in db
DoWork(attachments);
}
...
Inside DoWork();
I do:
foreach(var items in attachments)
{
//write attachment name to file here
}
In the database I have a total of 5 records which inside the first if
statement I get the appropriate results back. However in the second if
condition I get 0 result back in the query. Can someone tell me where I am going wrong please.
Please note both of the if conditions will be true.