EnumerableRowCollection<DataRow> query; if (checkType && checkCategory) query = from c in dtMax4SaleLimits.AsEnumerable() where (2==c.Field<Byte>("type") && lsn_cat == c.Field<String>("lsn_cat")) || (3==c.Field<Byte>("type") && lessontype == c.Field<Int32>("lessontype")) select c;