How to handle inheritance with datasource

2 posts, 0 answers
  1. Olivier
    Olivier avatar
    1 posts
    Member since:
    Jun 2019

    Posted 04 Jun 2019 Link to this post


    I would like to have a list of objects which all inherit of the same type but can have some specific properties.


    public class MyPrimaryClass
        public int CommonProperty { get; set; }
    public class MyInheritedClass1 : MyPrimaryClass
        public int SpecificProperty1 { get; set; }
    public class MyInheritedClass2 : MyPrimaryClass
        public int SpecificProperty2 { get; set; }


    And I would like to display these specific properties and if possible display each object in a specific format. Do you have an idea of how I can do that using telerik reporting ? I can't find any example or thread on this topic, but maybe I just didn't use the right key words ;)

    Thanks and regards,

  2. Eric R | Senior Technical Support Engineer
    Eric R | Senior Technical Support Engineer avatar
    438 posts

    Posted 06 Jun 2019 Link to this post

    Hi Olivier,

    When using an Inheritance Hierarchy for your database the best approach is to use Business Objects (POCO's) with an ObjectDataSource component. A sample is available in the How-To Bind to Business Object documentation.

    Additionally, the [DataObject] declaration in the sample will enable the ability to write specific methods and queries that can shape the data output in the ways you describe. 

    For example, the below methods from the sample get a list of products in different ways. 

    Sample Methods

    // Gets products bellow a specified max price.
    public IList<Product> GetProducts(decimal maxPrice)
        return this.GetAllProducts().FindAll(product => product.ListPrice <= maxPrice);
    // Gets products of specific model and a color.
    public IList<Product> GetProducts(int productModelID, string color)
        return this.GetAllProducts().FindAll(product => (product.ProductModelID == productModelID && product.Color == color));

    Please let me know if you have any additional questions and thank you for choosing Telerik Reporting.


    Eric R
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top