none
EF getting inherited object RRS feed

  • Question

  • I have a class BCD that inherits from the class PRODUCT.
    Then I have a method where I want to return the BCD object

    public static BCD ReturnProduct(int p)
            {
                var product = Db.Products.FirstOrDefault(p => p.ProductId == p);
                return product;
            }

    However here I am just bringing the product part.
    What should I do to bring also the BCD ?

    Monday, September 8, 2014 6:06 PM

Answers

  • Hello AGA,

    >>What should I do to bring also the BCD ?

    Trying with below query syntax:

    var product = Db.Products.OfType<BCD>().FirstOrDefault(p => p.ProductId == p);

    If this does not work for you, please share your model entities and context class with us.

    Best Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, September 9, 2014 5:38 AM
    Moderator