locked
Generic repository pattern for Table storage and EF RRS feed

  • Question

  • Is it possible to have a generic repository and UnitOfWork to store data in Table storage and EF.

    The service layer calls different repositories(regardless of where they are stored, some in TS and some in EF) and then UnitOfWork.SaveChanges(). The service uses the linq queries wisely knowing the limitations of Table storage.

    And in SaveChanges, through some conditional checking data is stored where it belongs. Is it possible?

    I think this question essentially boils down to generalising ObjectContext and TableServiceContext. Has anyone done this?

    Right now I have seperate UoW and Repositories for Table Storage and EF(becuase of objectcontext and TableserviceContext). Table servicecontext can be created internally from tableclient though (no need to get it through contructor)

    PS: transaction can be managed manually in SaveChanges() and is not a concern atleast for now

    Wednesday, August 22, 2012 2:46 PM

Answers

  • I believe you should be able to achieve with a bit of effort. As mentioned by you you need to make it happen through tableservice context only.

    Try to create an interface with storage provider as depedency, and have interface operations act on storage provider.

    There is a blog written on how to use EF for table storage. It might help you. take a look at this.



    Please mark the replies as Answered if they help and Vote if you found them helpful.

    • Marked as answer by Arwind - MSFT Tuesday, August 28, 2012 7:29 AM
    Thursday, August 23, 2012 6:00 AM