Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

breezejs with a repository

We have been looking closely at SPAs using Breezejs for providing the data context between the client and the server. The features look great on the client, but we want to use the Repository pattern on the server and get good separation of concerns without having to inherit from EFContextProvider which would cause problems with IoC and possibly unit testing/mocking. We have been following John Papa's Code Camper sample on Pluralsight which initially set out using a Respository/UoW pattern without Breeze which then led us to look at the Hot Towel template which does include Breeze.

Does anyone know how Breeze can be abstracted to a Repository which keeps the DbContext cleanly (if using Entity Framework) encapsulated. Also, what happens if you are not using Entity Framework and prefer to use another ORM such as nHibernate.

like image 737
SteveB Avatar asked Mar 20 '13 12:03

SteveB


1 Answers

Thanks for posting here as I am sure others will ask this :)

If you don't use EF then you won;t get the automatic metadata creation that Breeze provides. You can certainly abstract the EF context into a Repo however, and still get the benefits.

The Breeze/Knockout ASP.NET SPA template shows the repository broken out. I believe there is a sample for the UoW somewhere - tho it escapes me where. I have asked the Breeze folks to point to an answer for that.

If you use nHibernate there is no automatic metadata - however that is a great feature request I could see for Breeze.

like image 197
John Papa Avatar answered Sep 18 '22 00:09

John Papa