1
votes

I work in durandal project. I use breeze to retrieve and save my data. I want to send to the server, on saving, additional parameters other than the entity, like- who is the user that save the entity. but, function saveChanges of breeze accept only one parameter- entities array for saving.

what can I do?

1
Why dont you just update your model to include these fields? Or make each of your objects inherit from a base class that has these properties?Jamie Hammond
We've talked about adding a custom property that you can use to send any arbitrary serializable object. GO vote for that on user voice. Another alternative: a custom header.Ward

1 Answers

3
votes

You can use the SaveOptions.tag property. Something like this:

var so = new SaveOptions({ resourceName: "SaveWithComment", tag: "Whatever data you want" });
return myEntityManager.saveChanges(null, so);

The 'tag' property is made available on the server within the ContextProvider, so you can access it like this:

// within your server side ContextProvider
protected override bool BeforeSaveEntity(EntityInfo entityInfo) {
   var tag = (string)SaveOptions.Tag;
   ...

}