breeze

How can I detect a change to an entity's EntityState?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 09:40:24
I want to put a "Delete" button and a "Cancel" button on each row of a list of Customers. The "Cancel" button is disabled when a customer is "Unchanged". But when a customer transitions to a changed state ("Added", "Modified", "Deleted"), I want to enable the "Cancel" button so the user can reverse the changes -- whatever they are -- before saving. I can almost do this by subscribing to customer.entityAspect.propertyChanged . A property change signals a potential change in the EntityState . I can subscribe to that event and have my handler update an isChanged observable that I've added to my

Working with beforeSaveEntity and Navigation Properties

馋奶兔 提交于 2019-11-30 09:29:51
问题 My application allows the user to create products along with their UOM (Units of Measurement) and Barcodes During the creation process, API will check if there is no barcode entered, it will generate it automatically. That worked fine until I decided to add weight products that require scale barcodes with 7 digits. BeforeSaveEntity will ask if the product type is weight then generate 7 digits barcode, else, it will generate 13 digits. The problem is; I can't get this to work when checking the

Using this.Context inside BeforeSaveEntity

旧巷老猫 提交于 2019-11-30 04:55:35
问题 I was looking for a good way to organize validation rules within BeforeSaveEntity method and I have found this comment in the file: TodoContextProvider.cs within the project: BreezeMvcSPATemplate: // A second DbContext for db access during custom save validation. // "this.Context" is reserved for Breeze save only! Why this.Context can not be used? 回答1: Excellent question. The answer isn't obvious and it's not easy to cover briefly. I will try. The EFContextProvider takes the save data from

Translate breeze validation messages

自作多情 提交于 2019-11-29 22:56:48
问题 Improving my example on how to use the metadata obtained to create validation rules in knockout (http://stackoverflow.com/questions/13662446/knockout-validation-using-breeze-utility) now I use the validators that breeze inserts into the entities: function addValidationRules(entity) { var entityType = entity.entityType; console.log(entityType); if (entityType) { for (var i = 0; i < entityType.dataProperties.length; i++) { var property = entityType.dataProperties[i]; var propertyName = property

How to consume OData service with Html/Javascript?

谁都会走 提交于 2019-11-29 22:25:16
Our project currently uses Silverlight to consume an Odata service. This has made life pretty simple since we can just reference the OData service thus giving us generated service reference/entities. However there is some discussion on whether we should move to Html (html5). I'd like to know what to expect if we make this change. We'd be leveraging a framework like jQuery of course. My main concern is how to consume the same OData service via JavaScript/jQuery. How are we suppose to deserialize/serialize entities returned from this OData service? Is our data contract supposed to be hard-coded

How to properly send action parameter along with query in BreezeJs

寵の児 提交于 2019-11-29 17:53:25
问题 Currently I am calling all data queries as showed on BreezeJs docs / examples: getEntityList = function (predicate) { var query = new entityModel.EntityQuery().from("EntityList"); if (predicate) query = query.where(predicate); return manager.executeQuery(query); } But I want to pass additional parameter to controller action before any queryable result is returned: [AcceptVerbs("GET")] public IQueryable<Entity> EntityList(string actionParam) { //here goes logic that depends on actionParam /

Entity Framework object graph deletion with Breeze

坚强是说给别人听的谎言 提交于 2019-11-29 17:45:36
I am encountering a recurring problem that just makes no sense, and hoping someone (in the Breeze team?) can shed some light. The following model illustrates the entities in question. As you can see, I'm adhering pretty strictly to Entity Framework conventions in my property names, and as a result, if I check in SQL the cascade on delete rules are set by EF code first when it creates the db. Now, when I try to delete a BusUnit manually in SQL, the delete cascades correctly and the corresponding BusUnitDimensions are also deleted, as it should be. Likewise, if I delete a Dimension in SQL, the

from jQuery-ajax to breeze.js (SharePoint ODATA example)

丶灬走出姿态 提交于 2019-11-29 17:14:21
I am starting to use breeze.js for my ODATA service. I am using a SharePoint ODATA api and i have an example of how to use it with jQuery-Ajax. To make this work with breeze would be so f-ing awesome. Can anyone help me to translate this jQuery-Ajax call into breeze.js ? ... or push me in the right direction? $.ajax({ url: “../_api/SP.WebProxy.invoke”, type: “POST”, data: JSON.stringify({ “requestInfo”: { “__metadata”: { “type”: “SP.WebRequestInfo” }, “Url”: “http://get_my_data_from_this_url”, “Method”: “GET”, “Headers”: { “results”: [{ "__metadata": { "type": "SP.KeyValue" }, "Key": "Accept",

How should I create secondary DbContext using ContextProvider.EntityConnection?

纵饮孤独 提交于 2019-11-29 16:27:33
I'm using breeze with Code First EF. My production DbContext has IDatabaseInitializer that throws an exception if !context.Database.CompatibleWithModel(true) . If I create a context like suggested in the documentation database compatibility cannot be checked. // The following line will throw NotSupportedException. // Unable to verify the compatibility of the model because // the DbContext instance was not created using Code First patterns. var context2 = new MyDbContext(EntityConnection, false); // create a DbContext using the existing connection How should I instantiate DbContexts providing

breezejs: calling savecChanges for a classic ODATA service fails

萝らか妹 提交于 2019-11-29 16:12:01
I'm trying to save an Entity that was loaded using a classic WEBAPI ODATA service. When saveChanges is called on the client side, the modified entity is found and then the code goes into ´createChangeRequests´ and because the entityState is modified it goes into the function : function updateDeleteMergeRequest(request, aspect, prefix) { var extraMetadata = aspect.extraMetadata; var uri = extraMetadata.uri; if (__stringStartsWith(uri, prefix)) { uri = uri.substring(prefix.length); } request.requestUri = uri; if (extraMetadata.etag) { request.headers["If-Match"] = extraMetadata.etag; } } However