Click here to Skip to main content
15,902,938 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: I can hear the difference between linux and windows Pin
Dan Neely20-Jan-20 5:00
Dan Neely20-Jan-20 5:00 
GeneralBut can it run Doom? Pin
honey the codewitch19-Jan-20 15:13
mvahoney the codewitch19-Jan-20 15:13 
GeneralRe: But can it run Doom? Pin
Super Lloyd19-Jan-20 18:14
Super Lloyd19-Jan-20 18:14 
Rant.NET Core 2.2 vs .NET Core 3.1 Pin
Marc Clifton19-Jan-20 13:24
mvaMarc Clifton19-Jan-20 13:24 
GeneralRe: .NET Core 2.2 vs .NET Core 3.1 Pin
honey the codewitch19-Jan-20 15:15
mvahoney the codewitch19-Jan-20 15:15 
GeneralRe: .NET Core 2.2 vs .NET Core 3.1 Pin
Gerry Schmitz19-Jan-20 18:09
mveGerry Schmitz19-Jan-20 18:09 
GeneralRe: .NET Core 2.2 vs .NET Core 3.1 Pin
mmcdaniel20-Jan-20 3:33
mmcdaniel20-Jan-20 3:33 
GeneralRe: .NET Core 2.2 vs .NET Core 3.1 Pin
Richard Deeming20-Jan-20 8:46
mveRichard Deeming20-Jan-20 8:46 
I can't see how any version of Entity Framework would be able to translate a query using your computed property to a SQL query. It's quite likely that EF Core 2.x was loading the entire table into memory and evaluating the condition as a LINQ-to-objects query instead. One of the breaking changes in 3.x is that it won't do that any more.
Old behavior
Before 3.0, when EF Core couldn't convert an expression that was part of a query to either SQL or a parameter, it automatically evaluated the expression on the client. By default, client evaluation of potentially expensive expressions only triggered a warning.

New behavior
Starting with 3.0, EF Core only allows expressions in the top-level projection (the last Select() call in the query) to be evaluated on the client. When expressions in any other part of the query can't be converted to either SQL or a parameter, an exception is thrown.
There are a couple of ways around this. You could make the property a computed column[^]:
C#
modelBuilder.Entity<Client>()
    .Property(acct => acct.IsDeleted)
    .HasComputedColumnSql("CAST(IsNull(Deleted, 0) As bit)");
Or use you use a value converter[^] on the property:
C#
modelBuilder.Entity<Client>()
    .Property(acct => acct.IsDeleted)
    .HasColumnName("Deleted")
    .HasConversion(new BoolToZeroOneConverter<int>());
in which case, you'd want to remove the Deleted property, and possibly make IsDeleted writable.

Either option should allow your original query to be evaluated in the database, instead of in memory.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralI don't feel comfortable with this but i think it works Pin
honey the codewitch19-Jan-20 4:50
mvahoney the codewitch19-Jan-20 4:50 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 5:21
Mark_Wallace19-Jan-20 5:21 
GeneralRe: I don't feel comfortable with this but i think it works Pin
honey the codewitch19-Jan-20 5:33
mvahoney the codewitch19-Jan-20 5:33 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:06
Mark_Wallace19-Jan-20 21:06 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 9:12
mveOriginalGriff19-Jan-20 9:12 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:10
Mark_Wallace19-Jan-20 21:10 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 21:11
mveOriginalGriff19-Jan-20 21:11 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:13
Mark_Wallace19-Jan-20 21:13 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 21:28
mveOriginalGriff19-Jan-20 21:28 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:39
Mark_Wallace19-Jan-20 21:39 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 21:45
mveOriginalGriff19-Jan-20 21:45 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:54
Mark_Wallace19-Jan-20 21:54 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 22:06
mveOriginalGriff19-Jan-20 22:06 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace20-Jan-20 19:17
Mark_Wallace20-Jan-20 19:17 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff20-Jan-20 20:12
mveOriginalGriff20-Jan-20 20:12 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Richard Deeming20-Jan-20 8:53
mveRichard Deeming20-Jan-20 8:53 
GeneralRe: I don't feel comfortable with this but i think it works Pin
honey the codewitch20-Jan-20 9:47
mvahoney the codewitch20-Jan-20 9:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.