Partially allow 'is' pattern in expression tree #4825
Replies: 3 comments 3 replies
-
I'm not sure what you mean. Can you provide an example of where you're trying to use |
Beta Was this translation helpful? Give feedback.
-
There's a semantic difference between Reference types can override At a higher level, a much more important issue is that the expression trees were designed to carry the full semantic load of the expression through to the various query providers (LINQ for SQL, Entity Framework, etc) so they could use all of that information when generating the appropriate query. Adding partial support for newer features by lowering those to existing structures (essentially, throwing out some of the semantic information) makes it impossible to update those query providers as the key information they need is being thrown away. This is a classic example of a short term dirty trick that'll turn around and cause significant increased pain down the track. |
Beta Was this translation helpful? Give feedback.
-
I understand that there is a difference. using System;
using System.Linq.Expressions;
public class C {
public void M() {
Expression<Func<string,string>> f = x => x != null ? x : "a";
Expression<Func<string,string>> g = x => x ?? "a";
// Expression<Func<string,string>> h = x => x is notnull ? x : "a";
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently 'is' pattern is not allowed in expression meaning you cannot replace
== null
withis null
.I suggest to add support for null checks since they can be mapped to
==
for reference types.Beta Was this translation helpful? Give feedback.
All reactions