0

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

1
  • Which LINQ provider are you using? LINQ to SQL? Entity Framework? NHibernate? Something else? Commented Jan 20, 2013 at 19:41

2 Answers 2

1

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();
Sign up to request clarification or add additional context in comments.

Comments

0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.