4

I'm very new with breezejs and having a few questions.

I think that breezejs has very nice features so I can replace my own datacontext. However, I don't want breezejs to interact directly with the dbcontext layer. In fact, in my application, the Service layer only exposes ViewModels - not even the real Business models - to the Controllers . So i'm not so sure whether I can use Breeze or not, since in few Breeze's examples, I only saw Breeze interact directly with DBContext.

Thanks.

=========================================

Thanks Ward for the answer,

About the features that I like from Breeze is that it will help to reduce a lot of time to build my own client-side view models. And to build a SPA, maintaining client-side view models is really painful for me, especially my application have desktop app client and other hand-held device's apps as well. Also, to handle the mapping from a JSon object to Knockout - which means with each view models, I will need a mapper as well.

Currently, my architecture is like this:

Server-side: Repository layer <=> Service layer <=> Controllers (with the Web API that exposes to Client-side)

Controllers only can get the data (in format of a View Model) by sending request through Service.

So, my question is whether it is possible to make use of Breeze to query and also its integration with knockout.

tereško
  • 58,060
  • 25
  • 98
  • 150
mashix
  • 300
  • 3
  • 13

2 Answers2

3

Breeze never works directly with your DbContext; it works with the service model that you expose through endpoints on your service (e.g., Web API controller methods). But you certainly get the most value from Breeze when the client can query and save entities that are structurally the same as entities on the server.

You can retrieve ViewModels with Breeze - you can call almost any HTTP service method with Breeze. It's not clear to me how Breeze would help you manage those ViewModels on the client once you had retrieved them.

What features of Breeze seem "very nice" to you? Your answer to that question will help you determine if Breeze can be helpful with your preferred architectural style.

Ward
  • 17,793
  • 4
  • 37
  • 53
1

Querying data through Breeze without API controllers using DBContext directly should be no problem, saving might be harder but still manageable. I think the most complicated part is to get metadata to the client.

According to this SO answer, samples for exposing metadata from other sources that DBContext directly should be out in a week or so.

Meanwhile, check BreezeJS spa-template sample as there is repository pattern involved on the server side which makes it similar to your data access setup.

Community
  • 1
  • 1
gius
  • 9,289
  • 3
  • 33
  • 62