Can I use LINQ to retrieve only “on change” values?

前端 未结 5 818
死守一世寂寞
死守一世寂寞 2021-01-22 20:36

What I\'d like to be able to do is construct a LINQ query that retrieved me a few values from some DataRows when one of the fields changes. Here\'s a contrived example to illus

5条回答
  •  再見小時候
    2021-01-22 21:17

    You could use the IEnumerable extension that takes an index.

    var all = ds.Tables[0].AsEnumerable();
    var weatherStuff = all.Where( (w,i) => i == 0 || w.Field("Observation") != all.ElementAt(i-1).Field("Observation") );
    

提交回复
热议问题