lasseespeholt's answer is perfectly good (preferable, even - there's no point in doing a projection if you're going to throw away the result), but if you want to apply this more generally, you can use a query continuation:
var checkBoxes = from x in FindAll<CheckBox>()
where x.Checked
select new
{
RecordType = Type.GetType(x.Attributes["RecordType"]),
RecordId = Int32.Parse(x.Attributes["RecordId"])
} into y
where y.RecordType != typeof(DomainModel.Group)
select y;
Here I've changed the second variable from x
to y
to make it clear that it's distinct from the original x
, but you don't have to do that.
Another alternative which avoids calling Type.GetType twice but still putting the where
clause before the final projection is to use a let
clause (which introduces another projection itself, admittedly):
var checkBoxes = from x in FindAll<CheckBox>()
where x.Checked
let t = Type.GetType(x.Attributes["RecordType]")
where t != typeof(DomainModel.Group)
select new
{
RecordType = t
RecordId = Int32.Parse(x.Attributes["RecordId"])
};