1

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?

user5260143
  • 1,048
  • 2
  • 12
  • 36
  • 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 Feb 05 '14 at 15:51
  • 1
    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 Feb 07 '14 at 09:36

1 Answers1

3

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

}
Jay Traband
  • 17,053
  • 1
  • 23
  • 44
  • Thanks for that - this was useful for passing in additional API versioning info to the server without changing the interface – Rodney Jun 13 '17 at 02:50