I am using breezejs + angular with olingo Odata v2 as backend service. I am able to get metadata correctly from Odata in breeze with Navigation Properties. However, when I tried to create an entity with association to other Entities. What breeze generates for me is something like {"displayName":"may 13","id":-1,"FK_page_id":1,"position":3,"FK_status_id":1,"title":"may13","weightPercentage":76,"FK_widget_id":1}
When I called manager.saveChanges(), it tried to create a batch request. Inside the batch request, it tried to post to the entity type and all those linked entities. I don't think this is correct behavior. How can I save just to the Entity type and also add relations to other entities?
Related
I'm working on a project which uses Angular, Breeze and signalR. I want to send data changes using SignalR instead of ajax calls from client side. How can I save changes in the breeze data?
are you planning to send the entire object graph or just individual objects?
In case of individual objects it should be as easy as attaching them to the DBContext.
Object Graph will be another story.. don't even know how that will work with SignalR.
Im unsure how I should structure an AngularJS app logicwise. On the serverside I do it like this:
Request is handled by controllers
Controllers call a service with the incoming data
Services do database queries by calling the appropriate methods on the database layers
So on the client side I have the controllers that bind the scope to my logic, my JSON data objects and my Services.
Do I put everything that is not related to the scope into a seperate service?
Where do I put my data objects? Into a seperate service?
What about two way databinding? Doesnt that write back to my JSON data objects even if I dont want that?
How do I organize my run method? Do I group everything by resource and put it into ArticlesService.init() for instance?
Should my services keep the JSON data objects and do all the updating on the local and remote collection (as in delete a JSON object and then call a DELETE method on the remote server?)
When a drupal application is consuming a WCF service that we inherited, it sends an xml that should result in an entity framework parameter. After some schema changes, we updated the entity framework model (edmx file). The problem is that when the client calls the service (with the same code as before) the usageritem parameter is not properly deserialized.
The call send to the method is the following:
<UpdateUsager xmlns="http://tempuri.org/">
<usageritem xmlns:a="http://schemas.datacontract.org/2004/07/CNVGestion.Domain" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" z:Id="i1">
<EntityKey xmlns="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" xmlns:b="http://schemas.datacontract.org/2004/07/System.Data" i:nil="true"/><a:ADR1>7 rue Diffonty</a:ADR1> ....
The method that receives this call has the following header:
public string UpdateUsager(fUsagerItem usageritem, bool checkonly){
The edmx where the entity is declared has the following header
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="FRONT.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
I wanted to know if there could not be a problem between the fact that this edmx was generated before using sql server 2005 and we are using sql server 2012 now to update it and we only changed the ProviderManifestToken="2005"..
Thank you for your help
Your question is a bit ambiguous - does the call to your service fails before entering your method or, if not, do you mean the parameter is null or some of its properties are null?
If the latter, I can only guess that updating the Entity Framework model from the database, changed the property order in fUsagerItem class. You can manually inspect the .xsd file referenced by service's WSDL and see how WCF expects the XML to be. Change the serialization order of properties with [DataMember(Order = ?)] attribute, though you'll have to put those in designer-generated classes (which is a bad idea).
It is generally considered that you shouldn't directly use entity framework objects in web service, especially when you consume the service from other frameworks like PHP. You have more control over the serialization process when you create your own Data Transport Objects: you can hide some properties or introduce new ones that don't exist in your database. If you can persuade your client to change their implementation, I'd recommend using DTO classes in your sevice (AutoMapper can help a lot mapping DTO objects to entities and vice-versa).
I have a backbone.js application connecting to a REST API. I noticed that if you delete multiple models at once, seperate API request have to be sent for each model.
Is there any way to handle the delete request using 1 request?
You would need your server to expose an endpoint for deleting multiple models at once by passing IDs of the models to be deleted in the first place. If you have this available the common way to handle that would be to add a method to your collection called something along the lines of deleteByIds which would accept array of IDs and then this method would remove the models from the collection on successful delete request (if sync) or straight away before sending the delete request to the API endpoint which would make sure they are all removed from the server.
By default that's how RESTful interfaces work and batch processing is always a custom extension to RESTful interfaces so there is no out of the box way to do that and it might involve you doing some extra work both on the backbone client and on the backend.
I have just started exploring Backbone.js.
Upon submission of a form I would like Backbone.js to save the details to database.
How can I go about this?
Unless you are using HTML5 local storage in the client the responsibility for saving to the database is not with backbone.js. Backbone will talk to the server via Backbone.sync using a REST type request. Effectively it will make an http POST request to save a new record or an http PUT request to update a current record.
The difference between a new record and a current record is that the :id field of the record is not set for a new record and is set for an old record.
If you want a tutorial using Ruby Rails as your backend solution then you can look at this tutorial.
http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/
However you can use any backend server such as PHP, Java, Django etc as long as they meet the requirements of the REST interface that backbone.js uses.
If you overide Backbone.sync you can also get backbone.js to interface to pretty much any legacy http protocol as well.