javascript - Breezejs: Return a single entity from a parameterized query -
does breeze have .singleordefault()?
i'm getting feet wet breezejs -- cool! have case using parameterized query (so i'm using .withparameters() in breeze query).
my query return single entity. in fact, it's defined on webapi controller:
public myentity getthisspecialentity(int theparameter) {}
(note doesn't return iqueryable or ienumerable, entity.
the query executes, data comes breeze appears array of 1, entity in it.
now take data[0] , assign it, wondering if that's i'm supposed do, or if breeze has linq's .singleordefault() method?
you can return single entity. need return single result when manager executes query below:
for example, if have executegetquery function in datacontext service, pass in query object:
var executegetquery = function (query, observable) { return manager.executequery(query).then(function (data) { if (observable) { observable(data.results[0]); // here }
hope helps.
Comments
Post a Comment