-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
CompareString in VB Project will be evaluated locally #10707
Comments
@divega Any news? Is that a mistake from me or an issue? |
The function is taking 3 parameters. That is probably the cause of client evaluation. I am not sure about functions in VB. But in C#, string.Equals(str1, str2) would get translated to server. But if you use the overload with 3rd parameter of StringComparison then it is client evaluated. |
Thanks for your answere. This is a normal string comparisation. In EF 6 it works! And also with String.Equals is EF will evaluate it locally.
will generate the following output: Compiling query model: Do you need more informations or tests? Thanks in advance. |
@NoFear23m - Thanks for additional info. The query model generated using string.Equals is different from the First one. First one has 3rd parameter TextCompare. Not sure reason for this. |
@smitpatel @divega I have the Context in C# on .Net Standard -> then a DAL in VB on .Net Standard -> then a TestConsole. But if i have the Context in C# on .Net Standard -> then a DAL in VB in .Net 4.6.1 -> then a TestConsole. Is that a known scenario??? Please give me feedback. Thanks in advance ;-) |
@NoFear23m - i suspect this is because of method resolution in different tfms. We ran into similar issue in past see #6803 In brief summary, when your DAL is targetting netstandard2.0 then the code in DAL will resolve to method resolution available in netstandard only even though there are more suitable overloads present in runtime (.net 461). I suspect that is the reason when you convert your DAL to target net461 the method resolves to something which EF can translate and it works fine. If on netstandard string.Equals is being resolved to the method with TextCompare parameter, EF cannot translate it unless EF start understanding that specific overload (which could be difficult being C# vs F#) |
Many thanks for the answer. Now that I know where the problem is I can rebuild my project. However, I would note in the "Docs" that it can lead to problems when using .NEt standard. Most people do not use a profiler, watch the output, or turn on the log. This is where a huge performance problem arises. As I said, if you know it you can prevent it. Best regards |
This was fixed by #10923. Re-linq transforms expressions containing |
Hy at all. Sorry for my bad english ;-(
Today i was wondering about the logoutput from EF.
I have the following code:
EF Generates the following log:
It the log i can see the following line for example:
The LINQ expression 'where (CompareString([i].ViewModel, __$VB$Local_viewModelName_0, False) == 0)' could not be translated and will be evaluated locally.
Is that a mistake from my side? If yes, what can i do?
EF Version: 2.0.1
Visual Studio 2017 (15.5.3)
Language: VB.Net (!!) on .Net Standard 2.0
EF Core version: (found in project.csproj or packages.config)
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10 Pro x64 (1709) Build 16299.19
Many Thanks in advance
Sascha
The text was updated successfully, but these errors were encountered: