breeze , entity gets detached somehow between ui-router resolve and the controller

entity gets detached somehow between ui-router resolve and the controller


Tag: breeze

I'm trying to reject changes on a newly added entity (expecting breeze to set entityState to detached). Most times it works, but once in a while (mostly after I have already performed an entity create and reject), the rejectChanges call will fail because there is a null reference to the entityAspect.entityManager property.

I am getting my entity instance through "resolve" of ui-router on abstract parent state. Then in the abstract parent controller, I assign that instance to $scope. From then on I deal with $scope.myEntity instead of the resolved variable in my constructor. When I call entity This is my resolve function:

    myEntity:function(sharedEntityManager,$stateParams, $q){
      return  $q.when(sharedEntityManager.getMyEntity($stateParams.entityId))
          if(!myEntity && myEntity.entityAspect.entityState.isDetached()){
            return myEntity;

Then in my parent abstract controller, I call this:

$scope.myEntity = myEntity;

The error I get showing null entityManager...

TypeError: Cannot read property 'isRejectingChanges' of null
at __using (breeze.debug.js:449)
at EntityAspect.proto.rejectChanges (breeze.debug.js:3687)

The error seems to occur only after I have successfully done 1 cycle of creating entity, rejecting that entity. Then when I create another new entity, that new entity somehow goes from "Added" and having an entityManager, to "Detached" and null entityManager. I confirmed that in the resolve function, entityState is "Added", but in the controller constructor, the injected entity from ui-router is now "Detached".

Anyone familiar with this behavior and is there a work around?


Are you sure about the test in the then function? It seems off to me. Do you really mean if(!myEntity && ... or should it be if(!myEntity || ...)


“Unable to satisfy package dependency constraints” with Breeze.Server.WebAPI2

I am trying to add the Breeze.Server.WebAPI2 Nuget package to Visual Studio Community 2015 RC. When I click on install I get "Unable to satisfy package dependency constraints" The listed dependencies are: Microsoft.AspNet.WebApi.OData (>= 5.2.2 && < 6.0.0) Microsoft.AspNet.WebApi.WebHost (>= 5.2.2 && < 6.0.0) Breeze.Server.ContextProvider (=1.5.4) WebActivator I tried adding...

Generate metadata from interface breeze+Typescript

I have some models, and i want to use them in typescript, so that breeze can consume those models and build metadataStore, but don't know what to do, there is some methods to add properties by hand, but i want to build metadataStore from existing model This is my typescript...

breezejs EntityQuery fail,knockout.js,breeze
I'm playing around with the breezejs knockout Todo-list tutorial/template ( I decided to make a new Employees class and see if I could bind to a list of employees. The view references a variable in the VM 'results' which is supposed to be an observable array of employees. <section data-bind="foreach:...

BreezeJS - handling lookup tables across modules

We have a large application that allows the user to switch between different modules within the application. Each module needs to be able to save separately, so each module has it's own EntityManager. There are some lookup tables, though, that we would like to use across the application. If we...

Stop breeze from adding timezone

I don't want breeze to tack on the time zone information on the server, or the client. How do I turn this off? I have a SQL DATE field in the database- I don't want time. When working with DateTime variables in C#, I always want them set to midnight....

How to save child properties?

Breeze & Angular & MV* I get an invoice object and expand it's necessary properties: Customer, Details, etc. To access detail properties is easy, invoice.detail[n].property. And saving changes to existing properties (1 - n) is also easy. In my UI, I simply loop through my object vm.invoice.details to get &...

Authentication: “cannot execute _executeQueryCore until metadataStore is populated”

I am trying to add authentication to my mobile app, built using Angular and Breeze. In my app.js: app.config(function ($httpProvider) { $httpProvider.interceptors.push(intercept) }); //intercept runs on every http request and response //When there is a 401 error it uses broadcast to send an event to //the application scope function intercept($rootScope)...

Is it possible to see if a specific property changed on a modified entity?

When saving a certain entity I want to send a notification email if the Approved property of this entity has changed. if (changedEntity.Entity is Option) { // Pseudo if changedEntity.Entity.Approved changed { send notification() } } Is there a certain way to do this? Or can it be done by...

HotTowel: breeze.angular.js file missing

I am following John Papa's course [Building Apps with Angular and Breeze - Part 1] on Plural Sight to build Breeze-Angular SPA. I have included all references in index.html according to video. <script src="../Scripts/breeze.debug.js"></script> <script src="../Scripts/breeze.angular.js"></script> <script src="../Scripts/breeze.directives.js"></script> <script src="../Scripts/breeze.saveErrorExtensions.js"></script> <script src="../Scripts/$q.shim.js"></script> I am...

Breeze Fetch Strategy always goes remote

Im having a problem where breeze always goes to the server even though I've specified FetchStrategy.FromLocalCache. I created a test script below. Th initial query goes remote as as expected. The second query also goes remote(FetchStrategy.FromLocalCache). The third query(ExecuteQueryLocally) goes to local cache. From developer tools I can see there...

AngularJS throws exception when trying to saveChanges with breeze

I'm new to AngularJS and Breeze. I'm trying to save changes and have a problem with that. Here's my code: In controller: function update() { vm.loading = true; return datacontext.saveSettings().then(function () { vm.loading = false; // never gets called }).fail(function (data) { vm.loading = false; // never gets called });...

BreezeJs features already implemented by AngularJs?

I was suggested to use BreezeJs for an AngularJs project and I saw that it has some really interesting features. In my case the main interests would be in caching, tracking changes, some light querying, and validation. I think those features can be implemented at some level in AngularJs without...

Angular and Breeze multiple EntityManagers

My angular application uses Breeze and encapsulates the breeze calls within a datacontext service. How can I use this service with different EntityManagers? I am thinking that I need to abandon using the datacontext as an angular service in this situation, since it seems like it is going to require...

entity gets detached somehow between ui-router resolve and the controller

I'm trying to reject changes on a newly added entity (expecting breeze to set entityState to detached). Most times it works, but once in a while (mostly after I have already performed an entity create and reject), the rejectChanges call will fail because there is a null reference to the...

How to filter records using group functionality in BreezeJs

I'm developing a client app that uses breezejs and Entity Framework 6 on the back end. I've got a statement like this: var country = 'Mexico'; var customers = EntityQuery.from('customers') .where('country', '==', country) .expand('order') I want to use There may be hundreds of orders that each customer has made. For...

breezejs: is it possible to create a 'not in' predicate?

I know how to use the 'in' predicate: var predicate = new breeze.Predicate('id', 'in', ['value1', 'value2']); but is it possible to do a 'not in' and if so, what is the correct syntax ?...

Passing Authentication from WebApp to WebAPI using BreezeJS

I am having two web applications, one a SPA using AngularJS + BreezeJS and the other a WebAPI. We are building authorization in the WebAPI and the results get filtered based on user access. We want the user to sign-in into organization Azure AD in the SPA and pass the...

breeze.js not honoring the “noTracking” option when end point returns multiple result sets

Consider this breze query: return EntityQuery.from('myAPI') .noTracking(true) .using(manager).execute() .then(querySucceeded) .fail(queryFailed); My API is defined like this: [HttpGet] public object myAPI() { // var userId = get the users id from auth ticket var userPref = _contextProvider.Context.UserPreferences.Where(u => u.userId == userId); var userOptions = _contextProvider.Context.UserOptions.Where(u => u.userId == userId); return new...

Breeze.js getEntities returns no entity

Using Breeze.js coupled with an Web Api (with Entity Framework 6 Code First) I am unabled to get entities after a call to executeQuery(query). More specifically here is my call in javascript: entityManager.executeQuery(query) .then(function(data){ alert(data.results.length); // length > 0 --> has data !! alert(entityManager.getEntities().length); // == 0 has no...

Breeze URL generation for REST API and navigation properties

Ive been trying to use breeze with third party RESTful API - the API expects parameters of two types - deep linking like - localhost/request/5 for single entities (ie. request with id = 5) and parametrised queries using JSON encoded in URL (transformed by breeze with no problem). The main...

breeze.Predicate instruction valid with JavaScript but not with TypeScript

I successfully performs breeze predicates like this with Javascript: var p3 = new breeze.Predicate('items', 'any', 'serialNumber', breeze.FilterQueryOp.Contains, '12345'); So I search for any items where any of these items have a serial number which contains 12345. I need to performs same kind of query on a Typescript page but I...

BreezeJS modified route not working,breeze
My application has two databases with exactly the same schema. Basically, I need to change the DbContext based on what data I'm accessing. Two countries are in one Db and 4 countries in the other. I want the client to decide which context is being used. I tried changing my...

Breezejs, OData can't see navigation property entity in client for many to many relationship

I'm working on many to many relationship for BreezeJS/WebAPI/OData like this: Metadata: and get data with dataContext.Users.Include("Customers") is fine: but why in result user object doesn't have customers navigation property: I read this article but no luck still can't use user.customers() I'm totally stuck, please help me. Thanks in advance....

JSON.stringify failing due to breeze entityAspect nesting

We are trying to use loggly in our AngularJS/Breeze web portal and I am having some trouble when I am trying to send the error over the wire via $log.error (both the angular logging and loggly logging are in play here). Eventually there is a call to JSON.stringify which throws:...

Breeze: addEntityType with complexType (entityTypes aggregation)

I have .NET entity: public class Customer { public long Id { get; set; } public string FirstName { get; set; } public string MiddleName { get; set; } public string LastName { get; set; } public DateTime BornOn { get; set; } public string RegisteredAddress { get; set; }...

where in the breeze entity materialization pipeline can i set a non entity object's prototype?

this question is basically the same question I asked a few weeks ago... how to tap into mappingcontext.processAnonType... I marked the question as answered by mistake and since then have not been able to get any follow up. Basically what I am trying to figure out is a location within...

BreezeJS - Is there any way to use old style 'One controller to rule them all' with OData Web API?,odata,breeze
I would like to expose the SQL Server Views via OData Web API but I don't want to create separate controllers for each views as there are too many of them and they will only accept GET verb for all the views. I thought I can achieve this using BreezeController...

BreezeJS/WebApi OData minimal metadata,odata,breeze
I have an WebApi OData endpoint that I'm querying with BreezeJS, and I'm having an issue with the json payload. When I query the endpoint with BreezeJS, as opposed to directly querying the endpoint via url, the json payload is ~2x, and it appears to be because the response includes...

Using Dependency Injection with Breezejs

I am building an EntityFramework/WebApi back end. I want to decouple my WebApi from the Entity Framework, and utilize Dependency Injection so I can swap out the "data source" for the web API. I have been looking at the Unit of Work and Repository patterns. I also want to use...

BreezeJS: Indexed Cache

I'm working on a SPA utilising BreezeJS and AngularJS, handling lots of entities (one of the types has ~60k entities). This is not an ordinary website, it's made for a specific purpose. Most of the time the entities are shown in sortable, paged lists. The above mentioned mass of entities...

Using Breeze/EntityFramework/WebAPI with multiple databases

We currently have a Silverlight app that uses DevForce 2012. Like much of the Silverlight world, we've started porting over to HTML5. We will be using Angular backed by Breeze coupled with EntityFramework/WebAPI. Each of our customers has its own database, all sharing the same model. Since we have several...

Is there a way to ignore some entity properties when calling EdmxWriter.WriteEdmx

I am specifically using breezejs and the server code for breeze js converts the dbcontext into a form which is useable on the clientside using EdmxWriter.WriteEdmx. There are many properties which I have added JsonIgnore attributes to so that they don't get passed to the client side. However, the metadata...

Error missing the extra metadata for an update/delete entity

when saving (updating) opr delete Entities the "missing the extra metadata for an update/delete entity" Error is thrown. Breeze.Angular" version="1.1.1" Breeze.Angular.Directives" version="1.3.10" Breeze.Angular.SharePoint" version="0.10.0" Breeze.Client" version="1.5.3" Breeze.DataService.SharePoint" version="0.10.0" Breeze.Metadata.Helper" version="1.0.8" Read the Entites is no problem. When debugging breeze.labs.dataservice.sharepoint.js line 297 function updateEntityNode... metadata is obtained by Sharepoint, etag and...

BreezeJs - How to make simultaneous AJAX calls?

I wrote two Ajax calls that request data from stored procedures (in SQL Server), sp_ahtreatmentselect and sp_inventoryselect. Here is how the functions look like in the Breeze controller. [HttpPost] [ActionName("getinventories")] public object GetInventories(HttpRequestMessage request) { var data = request.Content.ReadAsFormDataAsync().Result; var opId = data["operationid"]; string query = "sp_inventoryselect @operationId"; SqlParameter operationId...

Breeze - Saving decimal type has wrong scale?

i'm using the latest Breezejs (1.5.3) for data operations in sql server with Entity Framework. The save operation is done successfully. the savemap has the decimal value with full scale but after update the field in DB has wrong scale (number of decimal points). e.g the savemap has the value...

Handling server exceptions with Breeze SaveChanges () method

I am using Breeze with Angular and EF 6 in my project and I have a form where I perform CRUD operations. I have this entity called: Car2Sale which is a many-to-many table (Id, CarId, SaleId). Id is the PK for this table while CardId and SaleId are FKs to...

Breeze importEntities

When my application loads, I am exporting few breeze entities and storing those in local cache so that later when I have to make use of those entities again, I import them back from local storage and execute the query locally. There is one entity that has 84389 rows. I...

Breeze - How to preserve changes to fkey property when using expand()

Breeze seems to be reverting the fkey property value when the query expands the associated navigation property -- even when using the preserveChange merge strategy. We need a way to preserve all changes. Steps: Modify an fkey property of an entity in the cache. Query from the server with expand...

Breeze underlying array is null error at save

I got the "500 (Internal Server Error) underlying error is null" error message when I want to save the entity I created. Scenario: the user opens a modal window where he can create/edit blog entry he can select tags he also can create new tags if there is a tag...

Web Api 2 Inheritance No route providing a controller name was found to match request URI

Basically I cannot get my Web Api 2 application to work. First of all here are my requirements. In my application I am creating a dozen of controllers ( ProductController, ItemController, SalesController...etc). There are 2 actions which are absolutely common in all my controllers: FetchData, PostData (Each controller then may...

Extending a breeze entity using TypeScript

I am developing a website using HotTowel and TypeScript. In John Papa's excellent PluralSight course, he extended a breezejs entity by creating a constructor and using 'Object.defineProperty' to extend it. For example, he added a property called fullName as follows. NB: metadataStore is the breezejs metadata store function registerPerson(metadataStore) {...

Identity in database and on entity level is not identity in breeze metadata

I have two entities, BlogEntry and BlogBody, both set up in the same way but BlogEntry ID field is not identity according to breeze metadata. I don't understand why. What I did so far: I tried to change the mapping data and not using fluent api, just using only fluent...

breeze: how to filter collection in count condition

I have a class named A, it has a property B who is a collection of class C, and I want to filter some records of A by A.B.count > 0, below is my tried queries: breeze.Predicate.create("B().length", ">", 0); breeze.Predicate.create("B()[0]", "!=", null); breeze.Predicate.create("B()","all","length", ">", 0); I got the error:TypeError: this._fnNode1...

Breeze.js OData v4 Error

I am trying to create a simple JavaScript application using Breeze.js version 1.5.3. It is to consume an OData v4 service. The service is created with ASP.NET WebApi 2. Included scripts: <script src="/js/jquery.min.js"></script> <script src="/js/underscore.js"></script> <script src="/js/q.js"></script> <script src="/js/datajs-1.1.3.js"></script> <script src="/js/breeze.debug.js"></script> Here is the code configuring Breeze's EntityManager: var serverAddress...

“EnableBreezeQuery is not an attribute” error mesage

After updating "Microsoft ASP.NET Web API 2.2 for OData" package to version 5.4.0 I get an error "EnableBreezeQuery is not an attribute" when applying the attribute on an Action of an ApiController. Is there a Fix for that? I am using breeze 1.5.3 . Thanks...

Hunting Down Save Result Bug

I was looking for help trying to hunt down a bug with hasChanges still true after returning from a successful saveChanges. I am saving an entity and nested entity together and when it returns my saveResult is showing as an array with the first object showing the parent entity and...

How to set up the column names in the query which is generated by Breeze in case of expand?

I have the db structure and EF context below and I want to query the blog entries. In this case blog entry means the blog_entry (including id and title fields) and blog_body including body_with_markup and body_without_markup fields. I have a query in Breeze like below and the result is that...

Breeze - Édit row in modal strategy

I've been using breeze with angularJS in my last few projects, but there's something I never had done right, at least with a good strategy. That's editing/adding rows in one modal. In the previous projets, my strategy was to clone the breeze objects into json objects and then editing that...

breezejs navigation refresh “There is no resourceName for this query”

I have a breeze js navigation property which all loads fine, but I want to refresh the navigation records so I've tried using the following code .loadNavigationProperty('PropertyDocuments') .fail((reason) => alert("Data refresh failed" + reason)); Which gives error There is no resourceName for this query What is the correct method...

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...