Strange! I just knocked together something similar:
private void button1_Click(object sender, EventArgs e)
{
List<Student> list = new List<Student>();
list.Add(new Student(10, 11));
list.Add(new Student(20, 21));
list.Add(new Student(30, 31));
list.Add(new Student(40, 41));
var c = from s in list
select new { A = s.A, B = s.B, sum = s.A + s.B };
foreach (var s in c)
{
Console.WriteLine("{0}:{1}+{2}", s.sum, s.A, s.B);
}
}
}
public class Student
{
public int A { get; set; }
public int B { get; set; }
public Student(int a, int b)
{
A = a;
B = b;
}
}
And I get what I would expect:
21:10+11
41:20+21
61:30+31
81:40+41
So when you say: "But I don't get any result" what do you get? Could it be that your
ssh.CourseID == CourseID
condition is selecting no records?