none
Dinamic Linq Query -- select between inner and outer join. RRS feed

  • Question

  • Suppose I have these following Linq queries. I want to write a single query and choose (possibly, by using an extension expression for .Join) between the inner and outer join. I'm a beginner in Linq so I really need your help, and some code snippets would be great.

    Code Snippet

    var query = from person in people

                    join pet in pets on person equals pet.Owner into gj
                   
    from subpet in gj.DefaultIfEmpty()
                   
    select new { person.FirstName, PetName = (subpet == null ? String.Empty : subpet.Name) };

    Code Snippet

    var query = from person in people

                    join pet in pets on person equals pet.Owner

                    select new { person.FirstName, PetName = (subpet == null ? String.Empty : subpet.Name) };


    Sunday, July 20, 2008 1:24 PM