David,

You can use DefaultIfEmpty to get your Left Outer Join
http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/c139313e-d745-4e1d-b3dc-ab355507eb48

Corneliu.

On Thu, Sep 23, 2010 at 12:37 PM, Arjang Assadi <[email protected]>wrote:

> If Anyone is intrested in Entity Framework the same problem is handled
> by drawing an association line in ER Designer. By using * -- 0..1
> mutiplicity
>
> On 23 September 2010 12:02, David Burela <[email protected]> wrote:
> > This has been solved.
> > For anyone that is interested, it has to do with the foreign key in the
> > DBML.
> > If the foreign key is not nullable it will do an inner join.
> > If you make the field nullable then it will do a left join.
> >
> > On 23 September 2010 10:28, David Burela <[email protected]> wrote:
> >>
> >> I am using LinqToSql on a project, and Ria services to expose it as an
> >> IQueryable.
> >> I want to send my Product table along with its child tables (e.g.
> >> ProductStatus, ProductCategory)
> >> To do this I am using the standard
> >>
> >> public IQueryable<Product> ProductSelect()
> >>
> >> {
> >>     DataLoadOptions loadOpts = new DataLoadOptions();
> >>     loadOpts.LoadWith<Product>(p => p.ProductStatus);
> >>
> >>     loadOpts.LoadWith<Product>(p => p.ProductCategory);
> >>     this.DataContext.LoadOptions = loadOpts;
> >>
> >>     return this.DataContext.Products;
> >> }
> >>
> >> Unfortunately this is creating inner joins, not left joins. There isn't
> >> referential integrity on the tables (I can't add it in). This means if
> the
> >> there isn't a matching record in the child table, then the product will
> not
> >> be selected.
> >> Does anyone know how to change this to be a left join?
> >> -David Burela
> >
>

Reply via email to