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
Post a Comment