I just came across a small problem where i had a table with 2 priority columns.
One is generated by the system and the other enabled users to manually override the generated priority.

I just came across a small problem where i had a table with 2 priority columns.

One is generated by the system and the other enabled users to manually override the generated priority.

The requirement was to sort the data by the highest of the 2 columns. The problem is the manual priority might be null.

To achieve this i found out about the very useful statement in LINQ called let.

The let statement allows you to define variables within your LINQ statement.

In the example below the first let statement handles the possible null column, the second finds the highest of the two allowing us to use it for sorting.

Check it out here:


var result = from c in dal.cases
        let sortOrderManual = c.ManualPriority == null ? 0 : c.ManualPriority
        let sortOrderHighest = c.Priority > sortOrderManual ? c.Priority : sortOrderManual
        orderby sortOrderHighest descending
        select c;

You may also like

Enhancing JIRA’s Issue Navigator

At Revium we use JIRA as our day to day issue tracker and workhorse. What we have found over time is that if you are working on a lot of projects your list of issues can get quite long.  So I decided to make a simple jQuery plugin that would group all my issues by project key and allow me to focus on one project at a time.

Keep Reading

Kentico 6.0 Custom BizForm Validation

We have been working with Kentico and their BizForms module for a while now to implement “simple” forms to capture data. But like any work you do that uses the word simple, it quickly becomes a complex form with conditional validation. Revium uses custom form controls to extend Kentico BizForms.

Keep Reading

Newsletter sign up

Every couple of months we send out an update on what's been happening around our office and the web. Sign up and see what you think. And of course, we never spam.