Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Linq query OrderBy fails when projecting to record type class having primary constructor #3213

Copy link
Copy link
Open
@joe-hamilton-wesd

Description

@joe-hamilton-wesd
Issue body actions

NHibernate Linq fails to convert OrderBy expression to SQL when projecting to a record type class that has a primary constructor. If I remove the primary constructor of the class I am projecting to then the OrderBy expression works.

//OrderBy fails if object projecting to has primary constructor:
public record SearchCoursesResult(
    Guid CourseId,
    string CourseName,
    Guid SubjectId,
    string SubjectName,
    string CourseLevel,
    string? CollegeCourseCode,
    bool CourseIsActive
    );

//OrderBy succeeds if object projecting to does not have primary constructor
public record SearchCoursesResult
{
    public Guid CourseId { get; init; }
    public string CourseName { get; init; }    
    public Guid SubjectId { get; init; }    
    public string SubjectName { get; init; }    
    public string CourseLevel { get; init; }    
    public string? CollegeCourseCode { get; init; }    
    public bool CourseIsActive { get; init; }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.