Skip to content

Feature request: support resources with injected DbContext #657

Closed
@bart-degreed

Description

@bart-degreed

Description

Getting a resource by ID with sparse fieldsets fails when that resource has a constructor to inject the DbContext, as described here: https://docs.microsoft.com/en-us/ef/core/modeling/constructors.

Example:

public sealed class User : Identifiable
{
    public User(AppDbContext context)
    {
    }
}

This fails because IQueryableExtensions.CallGenericSelectMethod (and a few other places) assumes the entity has a parameterless constructor, causing an exception to be thrown at the statement:

Expression.New(sourceType)

Environment

latest master branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions