Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't write CLR type with handler type Int32Handler #1436

Closed
killergege opened this issue Jun 30, 2020 · 1 comment
Closed

Can't write CLR type with handler type Int32Handler #1436

killergege opened this issue Jun 30, 2020 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@killergege
Copy link

killergege commented Jun 30, 2020

When moving from Core 2.2 to Core 3.1 and upgrading the lib Npgsql.EntityFramrworkCore.PostgreSQL from 2.2.0 to 3.1.4, I still have the issue reported and fixed by #489 but only in specific cases.
It seems that if the enum is a variable and is casted in the expression it fails, while if it "hard coded"or casted outside, it works.
It was working in 2.2

This works (hard coded enum):

public IQueryable<Request> GetFilter(IQueryable<Request> query)
{
   query.Where (r=>r.ApplicationId == (int)Applications.App1)
   return query;
}

This doesn't work (enum value in a variable) (throws InvalidCastException "Can't write CLR type Applications with handler typeInt32Handler"):

public IQueryable<Request> GetFilter(IQueryable<Request> query, Applications application)
{
   query.Where (r=>r.ApplicationId == (int)application)
   return query;
}

But this works:

public IQueryable<Request> GetFilter(IQueryable<Request> query, Applications application)
{
    var app = (int)application;
    query.Where (r=>r.ApplicationId == app)
   return query;
}
@killergege killergege changed the title Where queries with casted enum value throw Can't write CLR type Can't write CLR type with handler type Int32Handler Jun 30, 2020
@roji
Copy link
Member

roji commented Jul 24, 2020

Duplicate of #1281

@roji roji marked this as a duplicate of #1281 Jul 24, 2020
@roji roji closed this as completed Jul 24, 2020
@roji roji added the duplicate This issue or pull request already exists label Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants