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 Function support to LINQ DSL #134

Merged
merged 2 commits into from
Jul 9, 2024
Merged

Add Function support to LINQ DSL #134

merged 2 commits into from
Jul 9, 2024

Conversation

pnwpedro
Copy link
Contributor

@pnwpedro pnwpedro commented Jul 9, 2024

Problem

We want to expose support for calling User-Defined Functions via LINQ.

Solution

Collections and Indexes return sets whereas Functions can return anything. We could approach this a few ways, but I chose to make the existing QuerySource implementation work for functions. As such, the type declarations for functions are a little counter intuitive. Developers must type the Function based on the element type it returns. For example, if it returns a single value, T in Function<T> must be that type. If it returns an array or set, the T must be the type of the element in the array or set.

E.g. 1: If a function returns a string, the type definition must be Function<string>. The caller may call .Single() to get a single value back, or .ToList() to get a list with a single element.

E.g. 2: If a function returns an array or set of strings, the type definition must still be singular, such as Function<string>, similar to how one declares a Collection<T> or Index<T>.

Changes

  • Add DSL for Functions
  • Add array support to Page deserializer for cases when an array is returned and the DSL assumes we're interacting with a Page.
  • Add single value support to the Page and List deserializers for cases when a function returns a single value but, for example, the user wants to use the LINQ API to get a List.
  • Handle objects/primitives and arrays (in addition to sets) in Single/SingleAsync.
  • Accept a few misc IDE recommendations

@pnwpedro pnwpedro force-pushed the functions-in-linq branch from 452f5ec to 3050eb3 Compare July 9, 2024 15:06
@pnwpedro pnwpedro marked this pull request as draft July 9, 2024 16:00
@pnwpedro pnwpedro marked this pull request as ready for review July 9, 2024 17:25
@freels
Copy link
Member

freels commented Jul 9, 2024

Did you address #57 as part of this? Seems like it?

Copy link
Member

@freels freels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pnwpedro pnwpedro merged commit 4ec0618 into main Jul 9, 2024
5 checks passed
@pnwpedro pnwpedro deleted the functions-in-linq branch July 9, 2024 20:33
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