locked
Using OData with Repository Pattern RRS feed

  • Question

  • User-638259267 posted

    I have some new requirements for paging, sorting and filtering in my ASP.NET Web API Web application which I had previously designed to use a standard RESTful interface.  I am wrapping all of my Entity Framework operations currently using a Repository pattern along with using a DI container such as Unity to inject the appropriate Repositories.

    However, I am thinking that I may have to use ODataControllers to meet the paging, sorting and filtering requirements of my application, however, this implementation seems very tightly coupled to hooking into the Entity Framework Data Model.

    Is there a way to use OData with Web API without tightly coupling it to my Entity Framework Data Model and still retain the abstraction to use my Repository classes instead?  

    Please advise.  Any code samples/examples would be greatly appreciated.

    Thanks.

    Thursday, August 25, 2016 5:46 PM

Answers

  • User36583972 posted

    Hi vs2010junkie,

    You can refer the following tutorials. It described Entity Framework Database First to generate database entities and use a generic repository pattern and dependency injection / IoC to access entities through EF.The Repository uses generics and as such is not tightly-coupled on either end.

    Using C#, MVC, WebAPI, OData, Entity Framework, DI/IoC, and Kendo UI MVC and Efficient Data Retrieval:

    http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=634772&av=928984

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 26, 2016 5:59 AM