If I have a table with a title column and 3 bit columns (f1, f2, f3) that contain either 1 or NULL, how would I write the LINQ to return the title with the count of each bit
I think this is where LINQ falls down. If you want efficient use the SQL, if you want nice code, use LINQ.
You could always execute the query directly, since you know the SQL already.
class TitleCount {
public string Title;
public int Count1;
public int Count2;
public int Count3;
}
DataContext dc = new DataContext("Connection string to db");
IEnumerable query = dc.ExecuteQuery(
@"SELECT title,
COUNT(f1) as Count1,
COUNT(f2) as Count2,
COUNT(f3) as Count3
FROM myTable GROUP BY title");