1

Topic: The operator?:

The variable office matters null on an input. Here it produces an error... var lst = ctx. ClsClients. Where (s => s. Office == (String. IsNullOrEmpty (office)? 70: Int32.Parse (office))).ToList (); {System. InvalidOperationException: An exception was thrown while attempting to evaluate the LINQ query parameter expression ' Parse (value (ac.Controllers.HomeController+<>c__DisplayClass2_0).office) '.--> System. ArgumentNullException: Value cannot be null. Parameter name: String and it works... var lst = ctx. ClsClients. Where (s => s. Office == (String. IsNullOrEmpty (office)? 70: 20)).ToList (); Why so? Like one only expression should be calculated in the operator?:

2

Re: The operator?:

Hello, s_aa, you wrote: _> the Variable office matters null on an input. _> why so? Like one only expression should be calculated in the operator?: you transfer office in closing, hence in an amicable way office should be a constant, instead of a variable. And on each iteration of bypass ClsClients there will be a calculation?: and then and parsing office. You here the inconsistent invented Something.

3

Re: The operator?:

And then and parsing office. Here and interesting why? If value office remains null. Here the citation from the documentation the Parameter condition should matter true or false. If the parameter condition matters true, expression first_expression is calculated and the total of this calculation becomes result. If the parameter condition matters false, expression second_expression is calculated and the total of this calculation becomes result. It is anyway calculated only one or the other expressions.

4

Re: The operator?:

Hello, s_aa, you wrote:> and then and parsing office. _> Here and interesting why? If value office remains null. Here the citation from the documentation In case office not-null its parsing will happen every time memberwise ClsClients. Rewrite request on sql-like linq, with usage let.

5

Re: The operator?:

Hello, s_aa, you wrote: _> Why so? Like one only expression should be calculated in the operator?: the provider linq does not know that with int.parse to do.

6

Re: The operator?:

Hello, Sharov, you wrote: S> the Provider linq does not know that with int.parse to do. And the variable ctx in the code hints at a DB context. So that expression in this case is not calculated, and broadcast in SQL.

7

Re: The operator?:

_> Why so? Like one only expression should be calculated in the operator?: without knowing a context, it is difficult to answer. All works for me, aha. using System; using System. Collections. Generic; using System. Linq; class Program {static void Main (string [] args) {List <A> ClsClients = new List <A> (); ClsClients. Add (new A {Office = 70}); string office = null; var lst = ClsClients. Where (s => s. Office == (String. IsNullOrEmpty (office)? 70: Int32.Parse (office))).ToList (); Console. WriteLine (lst. Count ().ToString ());} class A {public int Office {get; set;}}}

8

Re: The operator?:

N> without knowing a context, it is difficult to answer. linq to entities it is used, ctx it DbContext

9

Re: The operator?: