I am attempting to combine different technologies, but I am facing challenges as the entity framework meta-datas are not being consumed properly by breeze.js. Despite setting up all configurations, it's proving to be a bit tricky since there are no examples to refer to. Below is a sample code that I have been working on, which is not functioning correctly. Hopefully, someone can identify my mistake and help solve this puzzle or use it as a starting point.
OdataService.ts
'use strict';
module twine.components {
class MetadataStoreOptions implements breeze.MetadataStoreOptions{
namingConvention:breeze.NamingConvention = breeze.NamingConvention.defaultInstance;
}
class Manager implements breeze.EntityManagerOptions {
metadataStore: breeze.MetadataStore;
constructor( public dataService: breeze.DataService) {
}
}
class DataServiceOptions implements breeze.DataServiceOptions {
serviceName = 'http://twine.azurewebsites.net/odata';
hasServerMetadata = true;
}
export class ODataService {
options: Manager;
manager: breeze.EntityManager;
metadataStore: breeze.MetadataStore;
storeOptions: MetadataStoreOptions;
static $inject: string[] = ['$http', '$rootScope'];
cache: twine.Model.IEntity[];
// Constructor and methods omitted for brevity
}
And this is tagController.ts
'use strict';
module twine.routes {
interface ITagsScope extends ng.IScope {
vm: TagsCtrl;
}
interface ITagsCtrl extends twine.components.ITwineRoute{
tags:any[];
getTags: () => void;
tag: any[];
getTag: (id:number) => void;
}
export class TagsCtrl implements ITagsCtrl{
/* @ngInject */
static controllerId: string = 'TagsController';
// Constructor and methods omitted for brevity
}
There are several errors encountered with different configurations, such as 'There is no resourceName for this query' or 'EntityKey must be set', which should not occur due to TypeScript's type checking. However, the issue lies in the configuration setup.
And this is abstract controller
[EnableCors(origins: "*", headers: "*", methods: "*")]
public abstract class EntityController<T> : ODataController where T: Entity
{
// Methods and routes omitted for brevity
}
And lastly this is ASP.NET webApi configuration
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Configuration and web-API services
// Routes and CORS setup
// Methods omitted for brevity
}
}
For testing purposes, there is a working backed OData service at
http://twine.azurewebsites.net/odata/Tag
. Feel free to access it as there are currently no CORS restrictions. If needed, the entity name can be changed based on the webApi configuration. I am open to providing the whole source code on github if required.
Update
Apologies for missing this earlier, the issue lies in the method Get
of ODataService. I am struggling to bind metadata from the server to breeze, as the fetchByEntityKey
method is throwing errors as mentioned earlier.