Home > Net >  Consult a great god lambda expressions one small problem
Consult a great god lambda expressions one small problem

Time:10-09

 GroupBy (x=& gt; X.C ycle_starttime). Select (g=& gt; (new {or=g. ey. The Month. The ToString (), count=right to mount (), g.S um (item=& gt; Item. Is_done? 1-0)})) 

The g.S um (item=& gt; Item. Is_done? 1-0), Is_done bool, so using the ternary operation complains, consult the should how to write

CodePudding user response:

You direct right to mount (item=& gt; Item. Is_done) not to go?

CodePudding user response:

Is it a null value?
Var q=g.S um (x=& gt; (x.I s_done?? False)? 1:0);

CodePudding user response:

The anonymous objects to the field name, otherwise an error
 
GroupBy (x=& gt; X.C ycle_starttime). Select (g=& gt; (new {or=g. ey. The Month. The ToString (), count=right to mount (), the sum=g.S um (item=& gt; Item. Is_done? 1-0)}))

CodePudding user response:

If you determine which g.S um (item=& gt; Item. Is_done? 1-0) Is_done are strongly typed properties,
  •  Tags:  
  • LINQ
  • Related