c# - Exclude linq join condition based on parameter -
i want able dynamically exclude join based on boolean parameters, @ code below, how can exclude join if 'includejoin' variable false or there way dynamically add joins class program { static void main(string[] args) { list<foo> foolist = new list<foo>(); foolist.add(new foo{foo_id = 1}); foolist.add(new foo{foo_id = 2}); list<bar> barlist = new list<bar>(); barlist.add(new bar{foo_id = 1}); barlist.add(new bar{foo_id = 1}); iqueryable<foo> fooquery = foolist.asqueryable(); iqueryable<bar> barquery = barlist.asqueryable(); bool includejoin = false; var foos = f in foolist //exclude join if includejoin vairable false!! join b in barlist on f.foo_id equals b.foo_id g result in g.defaultifempty() select new foo { foo_id = f.foo_id }; var results = foos.tolist(); ...