breezejs with a repository
Asked Answered
A

1

6

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.

Aarau answered 20/3, 2013 at 12:12 Comment(0)
I
3

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.

Inness answered 20/3, 2013 at 12:15 Comment(6)
Good answer, John. We are working on making it easier to generate metadata on the server for any CLR model. Should be able to describe it very soon ... as in a week or two.Rabat
I've added a simple example of "UoW/Repository and model in separate project" to my backlog. To get it out quickly it will use EF ... because the focus is on the separation of concerns, not on the data access technology per se. The reader should be able to swap out EF at will once we demonstrate (elsewhere) how to create metadata for any modelRabat
I highly recommend Scott Allen's videos on Repository and UOW in the Pluralsight Design Patterns course ... perhaps the clearest, jargon-free exposition of these patterns I've ever seen.Rabat
Hi Ward, that sounds exciting :) Got an update on generating metadata for any CLR model, like you mentioned in your first comment?Functionalism
@Rabat is there an example of how to do it with a Uow? Or is there a way to have multiple repositories for a single breeze controller?Grigson
FYI Breeze's NHibernate backend does do automatic metadata generation.Lenis

© 2022 - 2024 — McMap. All rights reserved.