Skip to content

Support LINQ querying for records #3728

@onionhammer

Description

@onionhammer

Is your feature request related to a problem? Please describe.
Currently when invoking Select() for records, an exception is thrown

"Constructor invocation is not supported., Windows/10.0.19045 cosmos-netstandard-sdk/3.29.4"

Describe the solution you'd like
Support constructors to select the members specified in constructors and let the deserializer handle the rest.

Describe alternatives you've considered
There are no alternatives except to not use records or not use LINQ.

Additional context
Example:

// record
record UserRecord(string Id)
{
    public string? Name { get; set; }
}

// query:
query.Select(x => new UserRecord(x.id, x.Name));

could result in

SELECT c.id as Id, c.Name
FROM c

which yields

[
   { "Id": "12345", "Name": "Joe" }
]

and skips potentially large JSON properties

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions