tags:

views:

38

answers:

1

Hi,

I have the following code which builds a Generic List of Abc from a database query.

List<Abc> lAbc = DB.GetAbc();

var lRawData = from r in lAbc
               group r by r.Stage1Check into s
               select s.ToList();

This gives me a WhereSelectEnumerableIterator of Generic List of Abc - which is ok. I then write this data to an Excel sheet.

The problem is that I need to further filter this data. The object Abc contains a property called FilterProp which is a boolean. What I can't figure out is how to use Linq to filter lRawData where the FilterProp is true?

Mark

+1  A: 

you could do something like this

var lRawData = from r in lAbc
               group r by r.Stage1Check into s
               select s.Where(f=>f.FilterProp).ToList();

this filter lAbc after grouping.

rob waminal
Thanks rob - ended up with this var lRawData = from r in lAbc select r.Where(f => f.FilterProp).GroupBy(g => g.Stage1Check).ToList(). The group r by r.Stage1Check into s wouldn't compile.
markpirvine