Skip/Take parameter types misconfigured
See original GitHub issueHi. I’m trying to make EF Core work with pg_trgm extension. Here is stripped down sample application to demonstrate issue https://github.com/osovitskiy/npgsql-efcore-sample While simple query like
context.Parent.Where(x => x.Name.FuzzyMatches("foobar")).ToList();
executes fine, more complex query with pagination
var entities =
context.Entities
.Where(x =>
context.Entities
.Where(y => y.Name.FuzzyMatches(search))
.OrderBy(y => y.Name.WordSimilarity(search))
.Skip(skip)
.Take(take)
.Select(y => y.Id)
.Contains(x.Id))
.OrderBy(x => x.Name.WordSimilarity(search))
.ToList();
translates correctly
SELECT x."Id", x."Name"
FROM "Entities" AS x
WHERE x."Id" IN (
SELECT y."Id"
FROM "Entities" AS y
WHERE (y."Name" %> @__search_0) = TRUE
ORDER BY (y."Name" <->> @__search_0)
LIMIT @__take_2 OFFSET @__skip_1
)
ORDER BY (x."Name" <->> @__search_0)
but fails to execute with error System.InvalidCastException: Can't write CLR type System.String with handler type Int32Handler
because it tries to write @__search_0
parameter as Int32
.
Same expression works fine if I replace FuzzyMatches
call with any of string.Contains
/ EF.Functions.Like
/ EF.Functions.ToTsVector().Matches()
. Any suggestions?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Using Skip/Take on a type not know at compile-time
I'd like to write a function, that retrieves data from a database table page by page. The goal here is to save memory....
Read more >ORA-12700: invalid NLS parameter value
Cause: Either an attempt was made to issue an ALTER SESSION command with an invalid NLS parameter or value; or the environment variable(s)...
Read more >HDevelop User's Guide
This manual is a guide to HDevelop, the interactive development environment for the HALCON machine vision library. It is intended for users who...
Read more >Configuring parameters and parameter data types
Command objects use parameters to pass values to SQL statements or stored procedures, providing type checking and validation in ADO.NET.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Let’s revisit it after we port to preview7. So much is changing there that the problem may go away (or its resolution may be very different).
Revisiting this after a long time, and @austindrenski’s simplified repo works fine on EF Core 3.1. Many type mapping inference issues were fixed in 3.0, so it would make sense this works now.
If there’s still an issue here, please post back and I’ll revisit.