0

我是 linq 的初学者,并且有三个像这样的表(sql ce 3.5):课程:(PK)CourseCode,CourseName Class:(PK)ClassCode,FieldCode,ClassName ClsCrs:(PK)ClassCode,(PK)CourseCode

我想将此查询转换或重写为 linq 并将结果分配给组合框数据源:

`SELECT CourseName FROM class, clscrs, course WHERE
ClassTitel = @ClassTitel and class.classcode = clscrs.classcode and
clscrs.coursecode = course.coursecode`

我怎样才能做到这一点 ?

谢谢

4

2 回答 2

1

你可以试试这个

var query = (from c in db.class 
             from v in db.clscrs 
             from n in db.course 
             where c.ClassTitel=="yourinput" 
                 && c.classcode = v.classcode 
                 && v.coursecode = n.coursecode 
             select n.CourseName).ToList();
于 2013-01-20T19:52:11.887 回答
0

不清楚 ClassTitel 字段属于哪个表(假设类表)。还将集合名称替换为 EF 或 Linq to SQL 生成的名称

var query = from cl in db.class
            join cc in db.clscrs on cl.classcode equals cc.classcode
            join cs in db.course on cc.coursecode equals cs.coursecode
            where cl.ClassTitel == "value"
            select cl.CourseName;

comboBox1.DataSource = query.ToList();
于 2013-01-20T19:41:29.780 回答