Entity Framework can save you a lot of time when developing data operations in your application.  I am going to demonstrate some techniques to use calculated fields to filter or constrain your results in a LINQ to Entity query.

Before we get started, we’ll use a simple example of a Contact entity that has one or more Address entities associated with it:

public class Contact
{
	public int ContactId { get; set; }
	public string FirstName { get; set; }
	public string LastName { get; set; }
	public DateTime Birthday { get; set; }
	public List<Address> Addresses { get; set; }
}

public class Address
{
	public int ContactId { ...

The previous blog on Categorized Lists with LongListSelector demonstrated IGrouping implementation. If we play it right, we shouldn't have to touch the "Grouping" class to group using complex objects.

I'll use a playing card deck as a familiar data model that has categories to group on, i.e. the "Suit" that contains "Clubs", "Spades",  "Hearts" and "Diamonds" and where each card has a value from two through nine and including "Jack", "Queen", "King" and "Ace". The cards can appear in the LongListSelector with the Suit in the heading for each group and the value for each card making up the details ...

You can use LongListSelector as a glorified ListBox, but that cripples its true purpose. The real power  of LongListSelector is to display long categorized lists, enable a "People Hub" style "jump list" to navigate between groups in the list and to allow performant scrolling.

Grouping

The trick to get LongListSelector working is to properly group the data assigned to the LongListSelector ItemsSource. You can start with a simple flat list of objects, where each object has a property suitable for grouping. In the snippet below, "MyObject" has a "Category" property that the list will be grouped on....

You can access Sitefinity Form entries using GetValue(), but you may want to chug through new form columns without knowing what they are named. In the blog How to access Sitefinity Form Response Data Programmatically, Gary Campbell explores syntax that looks something like this:

var temp = formEntry.GetValue("MyFormColumnName");

You need to know "MyFormColumnName" to get the form entry value. Telerik hasn't surfaced methods to snag these easily, but using LINQ we can spelunk into a form's description and rip out what we want.

Get All Form Columns

To get all form columns including ...

The Problem

I wanted to be able to add items to a IList<T> but not at the beginning or end of the list—in order based on a sorting function I specified.  I could have used List<T>’s Sort() method that takes an IComparer<T> as a parameter, but then I would have to define a new comparer class for every class I wanted to store in the list (not to mention every time I wanted to sort one those types off of a different property). 

The Solution

Instead of this potentially bulky solution, I created a generic extension method that will ...