The user interface may offer a list of filters from the DataFields. The DESDA.FilterAttribute
lets the business logic dictate which DataFields are offered. It also determines
which string-type DataFields are including in a multi-field search, where the user
inputs a phrase and its searched against the list of DataFields.
When displaying filters, sometimes the user interface needs just the most common
properties and other times it needs all of them. The AutoGeneratePriority property
determines the priority of the DataField. The available priorities
are Always, Standard, Advanced, Complete, and Never.
To further assist the user, filters are often built using ranges of values, such
as when the user picks UnitPrice, the user can pick from $0-$99, $100-$199, and $200-up.
BLD provides the DESDA.RangeEntityFilterPickerAttribute and DESDA.DateRangeEntityFilterPickerAttribute
to supply the user interface with those ranges. The DESDA.RangeEntityFilterPickerAttribute
is used for numbers. The DESDA.DateRangeEntityFilterPickerAttribute is used for dates
and supports smart "relative date" rules.
Here are FilterAttributes associated with the Employee Entity class.
public class EmployeeMetadata
{
[DESDA.Filter(AutoGeneratePriority=DESDA.AutoGeneratePriority.Complete)]
public object BirthDate { get; set; }
[DESDA.Filter(InMultiFieldSearch=true)]
public object City { get; set; }
[DESDA.Filter(InMultiFieldSearch=true)]
public object FirstName { get; set; }
[DESDA.Filter()]
[DESDA.DateRangeEntityFilterPicker(new PeterBlum.DES.QuickRange[]
{PeterBlum.DES.QuickRange.ThisMonth,
PeterBlum.DES.QuickRange.LastMonth,
PeterBlum.DES.QuickRange.LastQuarter,
PeterBlum.DES.QuickRange.ThisYear,
PeterBlum.DES.QuickRange.LastYear,
PeterBlum.DES.QuickRange.NotSet,
PeterBlum.DES.QuickRange.NotSet},
new string[] {
"Label='3 years ago' StartDate-DateType='Relative' StartDate-PeriodType='Year' StartDate-PeriodOffset='-2' EndDate-DateType='Relative' EndDate-PeriodType='Year' EndDate-PeriodOffset='-2' EndDate-DayOffset='-1'",
"Label='1990s' StartDate-ActualDate='1990-01-01' EndDate-ActualDate='1999-12-31'",
"Label='2000s' StartDate-ActualDate='2000-01-01' EndDate-ActualDate='2009-12-31'"})]
public object HireDate { get; set; }
[DESDA.Filter(DESDA.AutoGeneratePriority.Always, InMultiFieldSearch=true)]
public object HomePhone { get; set; }
[DESDA.Filter(DESDA.AutoGeneratePriority.Always, InMultiFieldSearch=true)]
public object LastName { get; set; }
[DESDA.Filter(InMultiFieldSearch=true)]
public object Notes { get; set; }
[DESDA.Filter(AutoGeneratePriority=PeterBlum.DES.DataAnnotations.AutoGeneratePriority.Complete)]
public object TitleOfCourtesy { get; set; }
}
The Source Code Browser shows completed DataAnnotations. The FilterAttributes have
been highlighted.
In the next topic, you'll learn how to
identiy which DataFields should appear and their order in the user interface.
Open the Source Code Browser (C# only)