Hello all,
I'm using LINQ to SQL and I have a stored procedure which brings back a result set that looks like so:
Type Field1 Field2
5 1 1
6 2 0
21 0 0
I'm hoping to do a few things with this record set:
1) Have 3 groups of results, one that has values in both field1 and field2, one that has a value in field1 but not field2 and one that has zeros in field1 and field2.
2) I'm only interested in a subset of types. I have a list of type id's I'm looking for (say 5 and 21 for this example). Right now the type values are stored in an enumeration but I can move them to a better data type if appropriate.
I've gotten to where I can group each set but I'm unsure of how to limit the types so I only bring back those I'm interested in.
Here's what I have:
var result = from all in dataContext.sp(..variables...)
group all by all into list
let grp1 = (from a in list
where a.field1 != 0 && a.field2 != 0
select a)
let grp2 = (from b in list
where b.field1 == 0 && b.field2 != 0
select b)
let grp3 = (from c in list
where c.field1 == 0 && c.field2 == 0
select c)
select new { grp1, grp2, grp3 };
Any help is appreciated.