I'am beginner in linq and have three tables (sql ce 3.5) like this : course : (PK)CourseCode,CourseName Class : (PK)ClassCode,FieldCode,ClassName ClsCrs : (PK)ClassCode,(PK)CourseCode
I want to convert or rewrite this query to linq and assign results to a combobox data source :
`SELECT CourseName FROM class, clscrs, course WHERE
ClassTitel = @ClassTitel and class.classcode = clscrs.classcode and
clscrs.coursecode = course.coursecode`
how can i do this ?
thanks
you can try this
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();
Its not clear which table ClassTitel field belongs (assume class table). Also replace set names with those generated by EF or 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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.