c# - LINQ: Rewrite an inline query into Linq method style? -


how re-written using linq methods instead of inline query style?

var cp = datarow r in rptdatapkg.datasets.item(0).result.rows                 (r.field<string>("unititem") == "pc") &&                       (r.field<string>("unititem") == "hs") &&                       (r.field<string>("unititem") == "u")                 select new currprojected                  {                      doaddup = (r.field<decimal>("fld1") + r.field<decimal>("fld2"))                                  == r.field<decimal>("fld3")                 }; 

try following

var cp = rptdatapkg.datasets.item(0).result.rows   .cast<datarow>()   .where(r => (r.field<string>("unititem") == "pc") &&               (r.field<string>("unititem") == "hs") &&               (r.field<string>("unititem") == "u"))   .select(r => new currprojected                 {                     doaddup = (r.field<decimal>("fld1") + r.field<decimal>("fld2"))                               == r.field<decimal>("fld3")                }); 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -