0

I am developing a SPA using Angular-Breeze-WebAPI-EntityFramework.

Now Breeze uses the Entity Framework metadata information to create it's own Breeze models. We use this in our application for Breeze validation.

So far, it's all been nice and easy. Now we are having to create a search page (say for querying customers). The search can be by Customer.Name or by Product.Id (which would return a list of customers who have bought that product). The result is a ng-repeater, which displays Customer.Name, Order.LastPlaced etc.

if you are getting confused by the tables and columns, forget that. What I am only trying to get to is that, both the search object and the result object are not 1:1 with Entity tables (or objects). So obviously I feel the need to create a custom object (one for the search and one for the results). My question primarily is where and how do I create that object?

If I create it at the data layer, Breeze would have no idea of the metadata for each of the properties (since it uses EF for that).

I obviously can't create just a JavaScript object, since I will have to query the database (using EF) to search and populate the object.

So where does one create such a custom object (traversing multiple tables) such that Breeze still can figure out the metadata and perform validation and such when the need arises?

Thank you all.

filya
  • 31
  • 8

1 Answers1

1

You can create metadata on the client for types that the server either doesn't know about or doesn't have the schema for. See http://www.breezejs.com/documentation/metadata-by-hand.

Jay Traband
  • 17,053
  • 1
  • 23
  • 44
  • I would assume even an ordinary application would use hundreds of DTOs. Is the best possible approach really hand-coding the metadata for all of them? Just feels like there **has to be** a better way. – filya Apr 01 '14 at 21:12
  • Many of the DTO's in SPA applications are simply anonymous projections which breeze handles without any metadata at all. It's only if you want to link the results of multiple queries to one another that you need the metadata. We are working on a .NET reflection provider that will produce the basic breeze metadata associated with any .NET class, but there is no comparable concept for most NoSql databases like mongo where such metadata simply can't be gleaned from the model. Do you have any suggestions? – Jay Traband Apr 01 '14 at 21:12