我有一個學生名單,我想正如我在下面的代碼創建一個查詢,在那裏得到所有的項目,而不是由1:如何改進此LINQ TO SQL可查詢?
IEnumerable<Student> = ...
List<AnsweredTest> ats = new List<AnsweredTest>();
foreach (var s in students)
{
query = from at in Database.Current.AnsweredTests
where at.StudentId == s.StudentId
select at;
ats.Add(query.Single());
}
listView.ItemsSource = ats;
這是不好的表現。我希望讓自己清楚,如果不是,請讓我知道。
這個工程!在另一個答案我收到這樣的錯誤:http://stackoverflow.com/questions/10862491/unable-to-create-a-constant-value-only-primitive-types –