Take a look at our ASPX demo, specifically the search functionaltiy, you can find it HERE. You can download the source to those pages in the Forums > EntitySpaces Trial / Test Suite > Trial Version on the 2nd page. There is a special way to add the where operator, like this:
First we populate those search comboboxes next to each field like this:
Code:
protected ListItem[] PopulateSearchItemList()
{
ListItem[] items = new ListItem[11];
items[0 ] = new ListItem("", "");
items[1 ] = new ListItem("Equal", "Equal");
items[2 ] = new ListItem("Not Equal", "NotEqual");
items[3 ] = new ListItem("Greater Than", "GreaterThan");
items[4 ] = new ListItem("Greater Than Or Equal", "GreaterThanOrEqual");
items[5 ] = new ListItem("Less Than", "LessThan");
items[6 ] = new ListItem("Less Than Or Equal", "LessThanOrEqual");
items[7 ] = new ListItem("Like", "Like");
items[8 ] = new ListItem("Is Null", "IsNull");
items[9 ] = new ListItem("Is Not Null", "IsNotNull");
items[10] = new ListItem("Not Like", "NotLike");
return items;
}
Then, when they hit "Search" we see if the combobox has a value (the criteria/operator) and then populate the Where() clause like this:
Code:
private void LoadEntityForSeach(VEmployeesCollection coll)
{
esVEmployeesQuery q = coll.Query;
if(this.vdEmployeeID.SelectedValue != "")
{
esWhereOperand op = (esWhereOperand)Enum.Parse(typeof(esWhereOperand),
vdEmployeeID.SelectedValue);
q.Where(q.EmployeeID.OP(op, this.vtEmployeeID.Text, null));
}
if(this.vdLastName.SelectedValue != "")
{
esWhereOperand op = (esWhereOperand)Enum.Parse(typeof(esWhereOperand),
vdLastName.SelectedValue);
q.Where(q.LastName.OP(op, this.vtLastName.Text, null));
}
if(this.vdFirstName.SelectedValue != "")
{
esWhereOperand op = (esWhereOperand)Enum.Parse(typeof(esWhereOperand),
vdFirstName.SelectedValue);
q.Where(q.FirstName.OP(op, this.vtFirstName.Text, null));
}
// and so on ...
}
Notice the use of the OP operator .... and we turn the "value" of our ListItem, ie, new ListItem("Greater Than Or Equal", "GreaterThanOrEqual") into an esWhereOperand using Enum.Parse ...
Hope that helps, follow up if need be ...
EntitySpaces |
Twitter |
BLOG | Please honor our Software License