So I am using a table twice in my query, and I dont know of another way to only use it once. Here is my query:
var result = (from t1 in (from t1 in db.Students.Where(en => en.Progress == MyEnum.Accepted).GroupBy(en => en.Class).AsEnumerable()
join t2 in dbOther.Classes on t1.Key equals t2.Class
select t2)
join t3 in (db.Students).AsEnumerable() on t1.Class equals t3.Class into t4
select new
{
ClassNum = t1.Class,
StartDate = t1.StartDate,
Weeks = t1.Weeks,
Accepted = t4.Where(e => e.Progress == MyEnum.Accepted).Count(),
NotAccepted = t4.Where(e => e.Progress < MyEnum.Accepted).Count()
}).ToList();
I need to only get classes that have students in the accepted state. Then I want to get the classes and the count of its entire roster, even the students that are not accepted. Is there a better way to do this? It seems like reading from the same table twice is not the fastest way to do this.
Thank you for the help.