I am trying to write a LINQ statement that will pull all the items from a table where the column Type matches what the user selects in a dropdown menu but if no matches are found then it returns ALL the items from the table regardless of the Type. I have gotten it to return all the items that match the user’s selection but I cannot figure out what code needs to be added so that if no matches are found it defaults to pulling all the items in the table.
Current Code:
(from i in db.ItemTypeTranslations
join st in db.SectionTranslations
on i.ItemType.SectionID equals st.SectionID
where i.CultureID == 1 && i.ItemType.SectionID == SelectedSection
select new
{
st.SectionID,
st.Title,
i.ItemTypeName
}).ToList();