I created a PersonPart and attached it to my Employee type. It contains a first name and a last name and implements ITitleAspect
so that when I create a bunch of Employees, they don't all show up as "Employee" in the content list. Now I want to create a Projection that displays all employees ordered by their last name alphabetically.
How can I accomplish this? Is there any interface I can implement to make FirstName
and LastName
available as sort criteria?
public class PersonPart : ContentPart<PersonPartRecord>, ITitleAspect
{
[Required]
[DisplayName("First name")]
public string FirstName
{
get { return Retrieve(r => r.FirstName); }
set { Store(r => r.FirstName, value); }
}
[Required]
[DisplayName("Last name")]
public string LastName
{
get { return Retrieve(r => r.LastName); }
set { Store(r => r.LastName, value); }
}
public string Title
{
get { return LastName + " " + FirstName; }
}
}
To add new bindings in Orchard to use in custom queries, you have to add these bindings as following:
Bindings
page as following:then press on Add a New Binding
button.
Add a Binding
page, you will see all your records properties (it will not include your ContentPart
properties if it's does not has a ContentPartRecord
), which you can add new binding for them:Here, you can select the property you want to add binding for.
Display
text and Description
for your property binding:Edit Query
page: