Breeze MetadataStore in comparison to OData Metadata/CSDL - odata

I've read through the Breeze site, and found how one can populate Breeze's MetadataStore with OData metadata. I've also read the OData metadata capabilities (basically the CSDL definition) and skimmed through Breeze's metadata capabilities.
Two related questions on the subject:
How complete does Breeze cover the OData/CSDL metadata capabilities? I assume relationships entities and datatypes are all supported, but are there notable gaps to be aware of?
Can I export a Breeze MetadataStore (back) to CSDL? If not, is this on the roadmap of being supported? and if not :) how much of a coding effort would it be to add that support myself?
I guess this also relates to question #1 and to how close are the Breeze and OData metadata models to one another.
Thanks!

The Breeze "native" metadata format is a superset of what is available in the OData /CSDL. The idea was that we wanted to be able to support non-relational models and custom metadata in addition to what OData/CSDL does. In addition, we wanted something that was a bit more readable and used JSON as its native format and was easily extensible. I don't know of any gaps, but if you find any please let us know.
Exporting the metadata store as CSDL is not currently supported because it would be a lossy conversion. It certainly would be possible but for what purpose?.
Hope this helps.

Related

How can you use BreezeJS without Entity Framework and OData?

How can Breeze JS be used to consume a pure, simple, plain old RESTful API? Consider a web api endpoint that does not support OData and does not have Microsoft Entity Framework as the OR/M layer.
I see there's this Edmund's sample here, but I would like it to be more specific on how to manually setup BreezeJS metadata, since from what I understand about not having OData support is the fact that you lose out-of-the-box metadata resolution for the model consumed from an api endpoint. I quote from this Edmund example:
we have not yet described the Metadata Definition API properly. We ask that you rely on your intuition as you read this code ... your intuition will usually be correct. Please post questions to StackOveflow tagged with "breeze".
Is there any source of information on this topic that leaves intuition aside?
That Edmunds sample is so old, it pre-dates any of the documentation on how to write metadata.
Take a look at the Metadata by Hand topic in the BreezeJS documentation.

Breeze save bundle format

I am using Breeze JS and would like to implement a server with full CRUD functionality using Progress Openedge. The Breeze website talks a lot about being able to write your own server implementation but I can find no information describing the format of a save bundle that Breeze sends to the server. Does anyone know of any documentation or schema?
The documentation for this is buried in the DataServiceAdapters page. Look about halfway down, under the heading saveChanges (saveContext, saveBundle) -> promise.
There's an example of what the JSON looks like in this SO answer.
The SaveBundle is not documented for a very good reason: it has no definition in BreezeJS!
It could be any serialized object that your server requires to satisfy yoursaveChanges work flow. You can see that this is true by examining the a60_abstractDataServiceAdapter.js source in github:
proto._prepareSaveBundle = function (/*saveContext, saveBundle*/) {
...
throw new Error("Need a concrete implementation of _prepareSaveBundle");
};
Breeze does ship with an implementation b00_breeze.dataService.webApi that satisfies the expectations of the companion Breeze ASP.NET Web API helper classes such as ContextProvider. This implementation is worth studying if you decide to write your own server support code.
But it is only one of many possible implementations. An OData web server, for example, requires an entirely different package and format for "$batch" change-set saves. Only you know what's right for your "Progress Openedge" server.
All that said, we do delve into some critical aspects of the SaveBundle destined for Breeze Web API services in the documentation for "ContextProvider".
Feel free to follow-up with more specific questions after you've read that.

Custom queries with Breeze JS (Fiql + Breeze)

Im new to breeze js, I understand that breeze has it's own query language related to OData
But I am trying to get breeze js working with a custom query language, as an example FIQL is
one of the form to make queries to backend, can we get breeze run with this type of query language.
Overview of FIQL :-
http://jaxenter.com/tutorial-smarter-search-with-fiql-and-apache-cxf-46876.html
(this is not a technical answer, at the very most it's an advice)
As mentionned from their website documentation :
Today, out of the box, the Breeze product ships with adapters for the
ASP.NET Web API and for OData. It also ships with .NET components that
interface with the Entity Framework and that generate Breeze metadata
from an Entity Framework model; that EF model could be developed code
first or database first. The Breeze client is in no way limited to
these technologies; they are merely the first backend components
available; we’d be thrilled to help you adapt Breeze to your preferred
server stack.
First question is whether
1) you want breeze to actually create FICL queries on the client and send them to a FICL service. This involves translating a client side breeze EntityQuery into FICL url syntax. If so you would need to create a new a 'uriBuilder' adapter.
2) you want to translate a breeze query already sent to your service into FIQL syntax on the server so that you can further refine the query and then send it on to your FICL service. If so you would need to create a breeze DataService endpoint.
Both of these are certainly possible.
If you are looking at the 1st option, take a look at the 'b000_uriBuilder.xxx' files in the breeze GitHub repo under the 'src' directory. There should be two 'uriBuilder.xxx' files, one which translates an EntityQuery into OData syntax and another that translates the EntityQuery into a new 'json' query syntax. There is also additional information on this 2nd syntax here:
http://www.getbreezenow.com/documentation/query-using-json
Both of these 'uriBuilder's make use an internal 'visitor' framework that we have not yet documented but should be reasonably understandable by looking at the source.
If you are looking at the 2nd option, I would recommend looking at the link mentioned above and then taking a look at the 'breeze.node.js' repo and the 'breeze-sequelize' subdir within it. In this repo we take a serialized server side breeze EntityQuery and translate it into a 'Node' Sequelize query that we can apply to a variety of backends.
Another option is to contact our professional services arm, at breeze#ideablade.com and ask them to assist in building the adapters for you or to ask for more detailed technical help.

How to deliver metadata with BreezeJs and ASP.NET WebServices? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can i get data from web service (asmx) using BreezeJs?
My asmx web service returns DTO objects which are not related with datacontext. How can I automaticaly, deliver metadata to breeze, without using Metadata() method from dbcontext?
I have already looked over the Edmunds sample, but in this sample, we have to manually write metadata for each entity. Can I avoid it using asmx web service and DTO objects?
Breeze currently accepts metadata in only two formats, a native json format and a csdl ( also converted to json) format ( used by Entity Framework backed models). Note that you can also deliver this metadata in combinations of these formats. i.e. via multiple importMetadata calls to the same metadataStore.
For your example you will need to create the metadata for each of your 'DTO' types, but this typically isn't that onerous. If you have a lot of them you could also write a simple app that uses reflection to build the metadata for you.
If you have a biggish model you don't have to write the metadata by hand. There is an easier way: use EF as a metadata design tool!
Take a look at the FoosMetadataProvider in the DocCode.DataAccess.EF of the DocCode sample (download it). It generates metadata for a Foo class that doesn't actually exist in any database at all! You could model your DTOs as if they mapped to a database with EF.
Using EF as a metadata design tool is a fast way to generate metadata on the server for models that are not actually using Entity Framework for data access. Just pretend that it is ... and then ignore the MetadataDbContext thereafter.
You don't have to carry EF in your production code either. You could use it in a separate project strictly for purposes of generating metadata. Pour that metadata into a script (there's an example of that in DocCode as well). Remember ... you're only using EF as a design time modeling tool. No one has to know; I promise I won't tell.
p.s.: EF is pretty good at this modeling business. You're not abusing it and I don't think it's a hack. You're not using the full framework ... and so what. You don't use all of jQuery either; that didn't stop you from serving it to your clients on every page, right?

Is it possible to get underlying table name from the model in Entity Framework 4

In order to avoid magic strings when running the ExecuteStore command is it possible to get underlying table name [and columns] from the model in Entity Framework 4
Liam
I can't tell you if there is, but the best shot would be to dive into the metadata of the context.
This might help you, it is a documentation about the metadata of the EF. If you can't find it in the metadata, you are most likely out of luck.
Edit according to this (bottom of the page):
I have also been trying to query the mapping metadata. I wanted to find the metadata which describes how tables and entities are mapped and which stored procedures are mapped to entities. I was not able to find the metadata I needed via the MetadataWorkSpace. Afterwards Danny Simmons from Microsoft did let me know that this mapping metadata is not available publically and that it is something they have to do in a future release of the Entity Framework.
It seems to be impossible at the moment as this information is not publically avaiable; however, this is from 2008, so it might have changed in the meantime.
I'll quote Rowan Miller ...
Hi,
Unfortunately in CT4 there is no
public surface that allows you to find
what the table name is for a given
entity type. This is actually a
limitation of EF in general as we
don't have a public API to access the
mapping section of the model. This is
something we are working to improve at
the moment.
~Rowan
CTP 4 being a pre-production update to EF4, in this case. My only suggestion for bypassing this, evil as it is, is for you to try parsing the XML in the model directly, and strip the table names from that. Very evil, but it should be doable. Remember though that models can relate to multiple tables, or views, or combinations.

Resources