Is there a way to specify a multi-sort either as the query is being built or on the result set outputted by the QueryExpression?
*This post is locked for comments
Is there a way to specify a multi-sort either as the query is being built or on the result set outputted by the QueryExpression?
*This post is locked for comments
Hi
Related entity adding order by is not possible why don't use fetch xml in plugin?
This is what you are expecting:
QueryExpression query = new QueryExpression("opportunity") { ColumnSet=new ColumnSet("topic") }; OrderExpression order1 = new OrderExpression("topic", OrderType.Ascending); OrderExpression order2 = new OrderExpression("createdon", OrderType.Descending); query.Orders.Add(order1); query.Orders.Add(order2);
Also, you cannot add order attributes from related entity.
For LINQ with early bound, you will need the code generation utility:
msdn.microsoft.com/.../gg327844.aspx
For LINQ with late bound (I haven' tried this method yet):
msdn.microsoft.com/.../gg334415.aspx
or
msdn.microsoft.com/.../Hh210215.aspx
If this became too tricky, maybe you can break your query in two:
Apply the "main order" on the first query, and over the result, apply the second order filter.
Thank you for your answer. Is it possible to add an order attribute from a related entity?
you add multiple sort orders when using queryexpression
Microsoft.Xrm.Sdk.Query.QueryExpression query = new Microsoft.Xrm.Sdk.Query.QueryExpression();
query.Orders.Add(new Microsoft.Xrm.Sdk.Query.OrderExpression("firstname", Microsoft.Xrm.Sdk.Query.OrderType.Ascending));
query.Orders.Add(new Microsoft.Xrm.Sdk.Query.OrderExpression("lastname", Microsoft.Xrm.Sdk.Query.OrderType.Ascending));
query.Orders.Add(new Microsoft.Xrm.Sdk.Query.OrderExpression("birthdate", Microsoft.Xrm.Sdk.Query.OrderType.Ascending));
also check
msdn.microsoft.com/.../microsoft.xrm.sdk.query.queryexpression.orders.aspx
msdn.microsoft.com/.../microsoft.xrm.sdk.query.queryexpression.addorder.aspx
www.magnetismsolutions.com/.../dynamics_crm_2011_querying_data_with_queryexpression
Already tried multiple AddOrder methods and that did not work. To use LINQ I'd have to load CRM classes (using Xrm.cs) right?
Have u already tried mutiple .AddOrder on your Query expression?
Or use LINQ for your result and try multiple sort like this link suggest:
stackoverflow.com/.../multiple-order-by-in-linq
If this solves, please Like and mark as "Verified Answer"
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156