ObjectDataSource .NET Core Dependency Injection

3 posts, 0 answers
  1. Paul
    Paul avatar
    4 posts
    Member since:
    Oct 2019

    Posted 26 Oct 2019 Link to this post

    Is it possible to use .net core dependency injection into the object set as the data source to an ObjectDataSource?

    Such that...


    class Products
        private readonly IProductRepo _repo;
        public Products(IProductRepo repo
             _repo = repo;
        public IEnumerable<Prodcut> GetProducts()
  2. Nasko
    Nasko avatar
    1071 posts

    Posted 29 Oct 2019 Link to this post

    Hello Paul,

    The ObjectDataSource component accepts parameters: Using Parameters with the ObjectDataSource Component. In theory it is possible to use dependency injection into the object.

    If the scenario is more complex, you can also call the GetProducts() method yourself and assign the resulting IEnumerable directly to the Report.DataSource property.

    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
  3. Vitaliy
    Vitaliy avatar
    3 posts
    Member since:
    Aug 2017

    Posted 30 Jan Link to this post

    Hello Nasko,

    you wrote "In theory it is possible to use dependency injection into the object". Please, continue with solution. Could you provide a demo project? Or post here the code examples?

Back to Top