asp.net mvc Linq exclude values from other table

memy_gentil

New Member
I have an exhibition scenario.How do I exclude a list of available Stands below, from the drop down list I would show in the Exhibitor view.In Sql I would:\[code\]Select StandID, Description from Stand Where StandID not in (Select StandID from Exhibitor)\[/code\]Exhibitors register - and select the stand they want from a dropdown list (StandID/Stand) as per the model below:\[code\] public class Exhibitor{ public int ExhibitorID { get; set; } public string CompanyName { get; set; } public string ContactName { get; set; } public int StandID { get; set; } public virtual Stand Stand { get; set; } }\[/code\]The Stand Model is as follows:\[code\] public class Stand{ public int StandID { get; set; } public string Description { get; set; } public bool Booked { get; set; }}\[/code\]I can get a list of Stands as follows:\[code\]var stands = db.Stands.ToList().Where(s => s.Booked==false) .Select(s => new SelectListItem { Value = http://stackoverflow.com/questions/12735272/s.StandID.ToString(), Text = s.StandNumber +": " + s.Description + ": " + s.Size + ":
 
Back
Top