locked
How to get the list of my text product RRS feed

  • Question

  • Dear all,

    I have the following snipet model :

    Table I am interresting in this post are Product and ProductText

    In order to get my product information I was using such thing :

     
    var results = from p
                                            in context.Products
                                        where p.ProductTypeId == ProductType
    
                                        select new
                                        {
                                         p,
                                         Pictures=(from ph in p.ProductPhotoes where ph.ProductId==p.Id select ph).ToList(),
                                         Videos=(from pv in p.ProductVideos where pv.ProductId==p.Id select pv).ToList(),
                                         Texts = (from t in p.ProductTexts where t.ProductId == p.Id select t).ToList()
                                        };
                                       

    but in the same querry, I need to retrive the List of ProductText belonging to p.ProductId that will be stored in myProduct.Texts property. My product type class is define as follow :

    public class Product
        {
            [DataMember]
            public int ProductID { get; set; }
            [DataMember]
            public int ProductTypeID { get; set; }
            [DataMember]
            public string ProductName { get; set; }
            [DataMember]
            public bool HasMoreInfo { get; set; }
            [DataMember]
            public int? TagValue { get; set; }
            [DataMember]
            public List<Text> Texts { get; set; }
    
    
        }

    not sure if its correect way or anything better could be made. by waht I provide, I need to go through each collection and build a product type

    Any tips ?

    regards

    serge


    Your knowledge is enhanced by that of others.


    Friday, July 6, 2012 8:59 AM

All replies

  • Hi Serge Calderara,

    Welcome to MSDN Forum.

    I'm not clear about the problem, the query you posted has already queried out the 'Product' information, what you want next? The 'Texts' property in your 'Product' class is List<Text> type, but the last member in your select section is List<ProductText> type, it seems not compatible.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, July 9, 2012 6:34 AM
  • Hi Serge Calderara,

    Have you solved the issue? I look forward to hearing from you.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, July 16, 2012 3:25 AM