Skip to content

Hierarchyid in a parameter collection does not work in 8.0-rc1 with MSSQL #31912

@bachratyg

Description

@bachratyg

Repro code:
https://gist.github.com/bachratyg/d3a985224d29c48f51df8f7b1e49a32d

The same query expression (obviously different sql) used to work with EFC7.0 and EntityFrameworkCore.SqlServer.HierarchyId 4.0.0.

This is the generated query:

DECLARE @__ids_0 nvarchar(4000) = N'["/1/","/2/"]';

SELECT [s].[Id], [s].[Name]
FROM [Stuffs] AS [s]
WHERE [s].[Id] IN (
    SELECT [i].[value]
    FROM OPENJSON(@__ids_0) WITH ([value] hierarchyid '$') AS [i]
)

SQL Server returns the following error:

CLR types cannot be used as column types in OPENJSON function with explicit schema.
CLR types are not supported in WITH clause.

If the type of [value] is changed from hierarchyid to nvarchar(max) on the last line implicit conversion kicks in and the command runs just fine with the new pattern. Query plan looks the same. Or simply just revert to the old behavior for types that are not supposed to work. I'm guessing spatial is in the same bucket.

Environment

EF Core version: 8.0.0-rc.1.23419.6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0-rc1
SQL Server: 16.0.1050.5

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions