Take the 2-minute tour ×

I have this Database Structure




--- Date

I want to get a list of all seminars (including their Classes) that are not linked to an event, and occur after a certain date.

Select * 
from Seminar, SeminarClass 
Where (Seminar.SeminarId not in (select SeminarId 
                                 from EventSeminar) 
       and seminar.SeminarId = SeminarClass.SemianrId 
       and SeminarClass.Date > something);

How can I translate this to LINQ 2 Entities ?

(there is no such entity as EventSeminar, as it's only a navigation property)

trying to achive this with a few queries caused me some trouble as I can't use one's result as parameter to expect on the 2nd.. need some conversion that I don't know how to achieve:

var Seminars = from e in context.Event
                                .Where(x=>x.Seminar != null) 
               select e.Seminar;

var SC = from c in context.Seminar.Except(Seminars) select c;

Need some help...

share|improve this question
add comment

1 Answer

var q = from s in context.Seminars
        where s.Date > something
              && (!s.Events.Any())
        select s;

You don't show the navigation property in Seminar for the navigation through EventSeminar to Event, so substitute it in the above if I've guessed wrong.

share|improve this answer
SeminarClass has the date, but otherwise you pointed to the right direction - s.Event.Any() (I used count == 0). –  Dani Mar 7 '11 at 15:58
The cardinality of SeminarClass wasn't clear from your question. Do you have an answer now, or do you need help with that. If so, what is the cardinality of Seminar -> SeminarClass ? –  Craig Stuntz Mar 7 '11 at 16:12
add comment

Your Answer


