Quantcast
Viewing latest article 14
Browse Latest Browse All 38

Answer by Tarmil for F# query expression: How to do a left join and return on those records where the joined table is null?

I think this should do the trick:

query {    for student in db.Student do    leftOuterJoin selection in db.CourseSelection        on (student.StudentID = selection.StudentID) into result    where (not (result.Any()))    select student}

or a nested query:

query {    for student in db.Student do    where (query {        for selection in db.CourseSelection do        all (student.StudentID <> selection.StudentID)    })    select student}

Edit: since you're using FSharp.Data.TypeProviders, if you have a foreign key between these two tables then you should also have a property that gives the associated CourseSelections, something like this:

query {    for student in db.Student do    where (not (student.CourseSelections.Any()))    select student}

Viewing latest article 14
Browse Latest Browse All 38

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>