When John Papa posted about this new SPA template for MVC 4 Web API apps, I was very curious about breeze.js.
I currently work on an application, which uses DevForce 2012 as entity data model and was searching for how this model supports breeze.js.
I just wanted to build a simple MVC 4 project, which is able to fetch data from a table.
I thought that might be, what a controller looks like:
[BreezeController]
public class TodosController : ApiController
{
// ~/api/todos/Metadata
[HttpGet]
public string Metadata()
{
return // that's where I surely need help,
// because breeze.js really needs this, I think
}
// ~/api/todos/CustomEntities
[HttpGet]
public IQueryable<CustomEntity> CustomEntities()
{
var manager = MyStaticContext.EntityManager;
return new EntityQuery<CustomEntity> {EntityManager = manager};
}
}
Is it actually possible to run DevForce 2012 with breeze.js? I was googling quite some time now, but decent search results are yielded rarely. I'm sorry if it doesn't, but might the documentation lack of this, yet?
The best way to refactor DevForce with Breeze is to share (or copy) your existing Entity Framework model over to Breeze. As you may have seen in the documentation, you then wrap the Entity Framework context with the Breeze EFContextProvider to expose it as a WebAPI endpoint: http://www.breezejs.com/documentation/web-api-controller
For various technical reasons, Breeze does not consume the DevForce model directly, but you do have access to the equivalent save interceptors by subclassing the EFContextProvider(http://www.breezejs.com/documentation/custom-efcontextprovider) and can perform query interception in your subclassed ApiController (http://www.breezejs.com/documentation/web-api-controller).
Also note that Breeze supports EF's Complex Types, but does not yet support EF inheritance or EF many-to-many mappings with no payload. Edit: As of v1.3.1 Breeze now supports inheritance.
Hope this helps!