c# - Sort linq query result, when it has "First() and into Group" -


var qrylatestinterview = rows in dt.asenumerable()                                                               group rows new                           {                             positionid = rows["msbf_acc_cd"],                             candidateid = rows["msbf_fac_tp"]                           } grp                          select grp.first(); 

i want sort above results using msbf_fac_dt datetime column,

so did following changes

var qrylatestinterview = rows in dt.asenumerable()                          orderby rows["msbf_fac_dt"] ascending                          group rows new                           {                            positionid = rows["msbf_acc_cd"],                             candidateid = rows["msbf_fac_tp"],                             facilitydate = rows["msbf_fac_dt"]                           } grp                          select grp.first(); 

but not sort above msbf_fac_dt column , can here

you can order group before selecting first record:

var qrylatestinterview = rows in dt.asenumerable()                          group rows new                          {                              positionid = rows["msbf_acc_cd"],                              candidateid = rows["msbf_fac_tp"],                          } grp                          select grp.orderby(x=> x["msbf_fac_dt"]).first(); 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -