Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Order in Query Expression CrmService Classes excluding 0 (zero)

$
0
0

I have a requirement for a query ordered by an int field, called priority. This field could be null, equal or bigger than 0.

I would like to order first, by priority ascending excluding 0 (From 1 to X), and after by CreatedOn if priority is null or 0.

OrderExpression order1 = new OrderExpression();
order1.AttributeName = "priority";
order1.OrderType = OrderType.Ascending;

OrderExpression order2 = new OrderExpression();
order2.AttributeName = "createdon";
order2.OrderType = OrderType.Ascending;

query.Orders = new OrderExpression[] { order1, order2 };

With this ordering, the first elements have priority equal to 0. 

Actually, I have to do two queries and after join the DataSet, but I was wondering if this can be accomplish with one query, because I could have a next requirement of adding paging to the grids where this info is bind.


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>