在linq查询中筛选所选的可枚举项

asg*_*las 1 c# linq-to-objects

是否可以将下面的linq查询合并到一个查询中?

var checkBoxes = from x in FindAll<CheckBox>()
                 where x.Checked
                 select new
                 {
                     RecordType = Type.GetType(x.Attributes["RecordType"]),
                     RecordId = Int32.Parse(x.Attributes["RecordId"])
                 };

checkBoxes = from x in checkBoxes
             where x.RecordType != typeof(DomainModel.Group)
             select x;
Run Code Online (Sandbox Code Playgroud)

Las*_*olt 5

var checkBoxes = from x in FindAll<CheckBox>()
                 let recordType = Type.GetType(x.Attributes["RecordType"])
                 where x.Checked && recordType != typeof(DomainModel.Group)
                 select new
                 {
                     RecordType = recordType,
                     RecordId = Int32.Parse(x.Attributes["RecordId"])
                 };
Run Code Online (Sandbox Code Playgroud)