Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extendFuncMap to Predicate #37

Merged
merged 1 commit into from
Apr 22, 2021

Conversation

tschettler
Copy link
Contributor

Adding a function to extend the funcMap defined in FnExpr within the Predicate scope. This function is modeled after extendBinaryPredicateFn, This will allow adding functions that are available in OData 4, but that breeze does not have defined.

For example, adding a date function to the funcMap:

Predicate.extendFuncMap({date: {fn: (date: Date) => new Date(date).setHours(0, 0, 0), dataType: DataType.DateTimeOffset }});

Afterwards, we can employ the OData 4 date function in the predicate:

let predicate = new breeze.Predicate("date(startDate)", "eq", dateValue);

The workaround for this would be to use a pass-thru predicate:

let predicate = new breeze.Predicate("date(startDate) eq " + dateValue);

Original PR Breeze/breeze.js#202

@steveschmitt
Copy link
Member

Cool, thanks.

Out of curiosity, what's your server setup for testing with OData 4?

@tschettler
Copy link
Contributor Author

tschettler commented Nov 15, 2020

@steveschmitt Thanks! I use Microsoft.AspNet.Odata and also test against the public APIs referenced on XOData. I've authored a breeze-odata4 package that is basically an OData 4 shim for breeze, but haven't updated it to use breeze-client 2.x yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants