Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Do This Query
Message
De
13/11/2011 16:55:06
 
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Divers
Thread ID:
01528772
Message ID:
01528776
Vues:
64
J'aime (1)
> Parts = < === What goes here?

My guess:
    select new ClientProjectProductModel
    {
        ProductId = products.ProductId,
        ProductNumber = products.ProductNumber,
        ProductSeries = products.ProductSeries,
        Parts =  new ClientProjectPart
                 {
                     PartNumber = parts.PartNumber  // or whatever your properties are
                 }
    }).ToList();
Haven't even tried this, but it's probably the first thing I *would* try.

~~Bonnie


>I have 3 tables in a typical one-to-many-to-many relationship.
>
>
>tblClientProjectProducts
>    |_mmlClientProjectProductsParts
>        |_tblClientProjectParts
>
>
>I'm trying to create a query that returns a list of ClientProjectProductModel objects. This ClientProjectProductModel model
>has a list property called Parts. I want that populated also. So far I have
>
>
>List<ClientProjectProductModel> retVal = 
>    (from products in context.tblClientProjectProducts
>    join mml in context.mmlClientProjectProductsParts on products.ProductId equals mml.ProductId
>    join parts in context.tblClientProjectParts on mml.PartId equals parts.PartId
>    where products.ClientProjectId == ClientProjectId
>    select new ClientProjectProductModel
>    {
>        ProductId = products.ProductId,
>        ProductNumber = products.ProductNumber,
>        ProductSeries = products.ProductSeries,
>        Parts =                                      <=== What goes here?
>    }).ToList();
>
>
>I'm unsure as to how to add in the parts. Can someone show me how to do this>
>
>Thanks
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform