I just want to order descending like this:
var query = from o in oEntite_T.ORDRE
where o.DATE_CREE >= datedeb && o.DATE_CREE <= datefin
orderby o.NO_ORDRE descending
select o;
It does not order descending, and I also tried:
var query = (from o in oEntite_T.ORDRE
where o.DATE_CREE >= datedeb && o.DATE_CREE <= datefin
select o).OrderByDescending(p => p.NO_ORDRE);
I got the same result. Is this because the component Devexpress?
linqServerModeSource_Ordre.KeyExpression = "NO_ORDRE;CODE_CLIENT";
linqServerModeSource_Ordre.QueryableSource = oOrdre_BL.Get_OrdreEntity(dateEdit_Deb_Ordre.DateTime, dateEdit_Fin_Ordre.DateTime);
gridControl_Liste_Ordres.DataSource = linqServerModeSource_Ordre;
My complete code:
public IQueryable<ORDRE> Get_OrdreEntity(DateTime datedeb, DateTime datefin)
{
try
{
IQueryable<ORDRE> LesListe;
Soft8Exp_ClientEntities oEntite_T = new Soft8Exp_ClientEntities();
var query = (from o in oEntite_T.ORDRE
where o.DATE_CREE >= datedeb && o.DATE_CREE <= datefin
select o).OrderByDescending(p => p.NO_ORDRE);
//var query = oEntite_T.ExecuteFunction<ORDRE>("qf").;
LesListe = query;
return LesListe;
}
catch (Exception excThrown)
{
throw new Exception("Err_02", excThrown);
}
}
From the code I see that you return the query object to some external infrastructure (set DataSource property of a devexpress component). Then I'd day that this component just adds another .OrderBy to this query when it executes it object so your sorting is lost.
It seems to be very possible and logical since devexpress have their own sorting capabilities which seem to just override yours.
By setting DataSource you just provide a data set, and it is up to the component to add sorting, paging, etc.
So look at the component API in order to specify sorting that you need. Perhaps it has properties to do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.