I'm not sure if this a breeze or an OData question: I would like to use orderBy
but using the max of two properties.
So for example the following would sort the list wrongly if an animal has no height specified or a height that is smaller than the animal type's minimal height:
breeze.EntityQuery.from("Animal").orderBy("height, toAnimalType.minimalHeight", true);
I'm thinking of something in the range of:
breeze.EntityQuery.from("Animal").orderBy("max(height, toAnimalType.minimalHeight)", true);
I looked at the OData functions under chapter 4.5 but I think it is the wrong way as A) there is no min
/max
and B) those are $filter
-functions (not orderBy-functions)
In reference to John Papa's model factory:
(function() {
'use strict';
var serviceId = 'model';
angular.module('app').factory(serviceId, model);
function model() {
// revealing module pattern
var entityNames = {
client: 'Client',
order: 'Order'
... other entity names
};
var service = {
configureMetadataStore: configureMetadataStore,
entityNames: entityNames
};
return service;
function configureMetadataStore(metadataStore) {
registerClient(metadataStore);
};
//#region Internal Methods
function registerClient(metadatastore) {
metadatastore.registerEntityTypeCtor('Client', client);
function client() {
// add calculated 'display' property to client model
// here is where you'd decide min or max
Object.defineProperty(client.prototype, 'display', {
get: function() {
var cn = this.companyName;
var st = this.state;
return cn.padRight('.',60) + st;
}
});
}
Haven't worked with this for a couple years as I do all ng4 and Typescript now so it may be a bit rough but might give you an idea. Recommend the Pluralsight courses for all this stuff. See if you can find the sample code for John Papa's Hot Towel Spa for Angular on github.