本文整理汇总了C#中OrderBy.Add方法的典型用法代码示例。如果您正苦于以下问题:C# OrderBy.Add方法的具体用法?C# OrderBy.Add怎么用?C# OrderBy.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderBy
的用法示例。
在下文中一共展示了OrderBy.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateUOMNameFilter
// Get the filters' data for UOMNameFilter.
protected virtual void PopulateUOMNameFilter(string selectedValue, int maxItems)
{
this.UOMNameFilter.Items.Clear();
// Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_UOMNameFilter function.
// It is better to customize the where clause there.
// Setup the WHERE clause,
WhereClause wc = this.CreateWhereClause_UOMNameFilter();
// Setup the static list items
// Add the All item.
this.UOMNameFilter.Items.Insert(0, new ListItem(this.Page.GetResourceValue("Txt:All", "FPCEstimate"), "--ANY--"));
OrderBy orderBy = new OrderBy(false, false);
orderBy.Add(UOMTable.UOMName, OrderByItem.OrderDir.Asc);
string[] values = UOMTable.GetValues(UOMTable.UOMName, wc, orderBy, maxItems);
foreach (string itemValue in values)
{
// Create the item and add to the list.
string fvalue;
if ( UOMTable.UOMName.IsColumnValueTypeBoolean()) {
fvalue = itemValue;
}else {
fvalue = UOMTable.UOMName.Format(itemValue);
}
ListItem item = new ListItem(fvalue, itemValue);
this.UOMNameFilter.Items.Add(item);
}
// Set the selected value.
MiscUtils.SetSelectedValue(this.UOMNameFilter, selectedValue);
}
示例2: PopulateParentCatIDFilter
// Get the filters' data for ParentCatIDFilter.
protected virtual void PopulateParentCatIDFilter(string selectedValue, int maxItems)
{
this.ParentCatIDFilter.Items.Clear();
// Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_ParentCatIDFilter function.
// It is better to customize the where clause there.
//Setup the WHERE clause.
WhereClause wc =this.CreateWhereClause_ParentCatIDFilter();
// Setup the static list items
// Add the All item.
this.ParentCatIDFilter.Items.Insert(0, new ListItem(this.Page.GetResourceValue("Txt:All", "FPCEstimate"), "--ANY--"));
OrderBy orderBy = new OrderBy(false, false);
orderBy.Add(CategoryTable.CatName, OrderByItem.OrderDir.Asc);
System.Collections.Generic.IDictionary<string, object> variables = new System.Collections.Generic.Dictionary<string, object> ();
string noValueFormat = Page.GetResourceValue("Txt:Other", "FPCEstimate");
CategoryRecord[] itemValues = null;
if (wc.RunQuery)
{
int counter = 0;
int pageNum = 0;
FormulaEvaluator evaluator = new FormulaEvaluator();
do
{
itemValues = CategoryTable.GetRecords(wc, orderBy, pageNum, maxItems);
foreach (CategoryRecord itemValue in itemValues)
{
// Create the item and add to the list.
string cvalue = null;
string fvalue = null;
if (itemValue.CatIDSpecified)
{
cvalue = itemValue.CatID.ToString();
if (counter < maxItems && this.ParentCatIDFilter.Items.FindByValue(cvalue) == null)
{
Boolean _isExpandableNonCompositeForeignKey = CategoryTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(CategoryTable.ParentCatID);
if(_isExpandableNonCompositeForeignKey && CategoryTable.ParentCatID.IsApplyDisplayAs)
fvalue = CategoryTable.GetDFKA(itemValue, CategoryTable.ParentCatID);
if ((!_isExpandableNonCompositeForeignKey) || (String.IsNullOrEmpty(fvalue)))
fvalue = itemValue.Format(CategoryTable.CatName);
if (fvalue == null || fvalue.Trim() == "") fvalue = cvalue;
ListItem newItem = new ListItem(fvalue, cvalue);
this.ParentCatIDFilter.Items.Add(newItem);
counter += 1;
}
}
}
pageNum++;
}
while (itemValues.Length == maxItems && counter < maxItems);
}
// Set the selected value.
MiscUtils.SetSelectedValue(this.ParentCatIDFilter, selectedValue);
}
示例3: PopulateUOMIDDropDownList
// Fill the UOMID list.
protected virtual void PopulateUOMIDDropDownList(string selectedValue, int maxItems)
{
this.UOMID.Items.Clear();
// 1. Setup the static list items
// Add the Please Select item.
this.UOMID.Items.Insert(0, new ListItem(this.Page.GetResourceValue("Txt:PleaseSelect", "FPCEstimate"), "--PLEASE_SELECT--"));
// 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_UOMIDDropDownList function.
// It is better to customize the where clause there.
WhereClause wc = CreateWhereClause_UOMIDDropDownList();
// Create the ORDER BY clause to sort based on the displayed value.
OrderBy orderBy = new OrderBy(false, false);
orderBy.Add(UOMTable.UOMName, OrderByItem.OrderDir.Asc);
System.Collections.Generic.IDictionary<string, object> variables = new System.Collections.Generic.Dictionary<string, object> ();
// 3. Read a total of maxItems from the database and insert them into the UOMIDDropDownList.
UOMRecord[] itemValues = null;
if (wc.RunQuery)
{
int counter = 0;
int pageNum = 0;
FormulaEvaluator evaluator = new FormulaEvaluator();
do
{
itemValues = UOMTable.GetRecords(wc, orderBy, pageNum, maxItems);
foreach (UOMRecord itemValue in itemValues)
{
// Create the item and add to the list.
string cvalue = null;
string fvalue = null;
if (itemValue.UOMIDSpecified)
{
cvalue = itemValue.UOMID.ToString().ToString();
if (counter < maxItems && this.UOMID.Items.FindByValue(cvalue) == null)
{
Boolean _isExpandableNonCompositeForeignKey = ScopeTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(ScopeTable.UOMID);
if(_isExpandableNonCompositeForeignKey && ScopeTable.UOMID.IsApplyDisplayAs)
fvalue = ScopeTable.GetDFKA(itemValue, ScopeTable.UOMID);
if ((!_isExpandableNonCompositeForeignKey) || (String.IsNullOrEmpty(fvalue)))
fvalue = itemValue.Format(UOMTable.UOMName);
if (fvalue == null || fvalue.Trim() == "")
fvalue = cvalue;
ListItem newItem = new ListItem(fvalue, cvalue);
this.UOMID.Items.Add(newItem);
counter += 1;
}
}
}
pageNum++;
}
while (itemValues.Length == maxItems && counter < maxItems);
}
// 4. Set the selected value (insert if not already present).
if (selectedValue != null &&
selectedValue.Trim() != "" &&
!MiscUtils.SetSelectedValue(this.UOMID, selectedValue) &&
!MiscUtils.SetSelectedDisplayText(this.UOMID, selectedValue))
{
// construct a whereclause to query a record with UOM.UOMID = selectedValue
CompoundFilter filter2 = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null);
WhereClause whereClause2 = new WhereClause();
filter2.AddFilter(new BaseClasses.Data.ColumnValueFilter(UOMTable.UOMID, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false));
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator);
// Execute the query
try
{
UOMRecord[] rc = UOMTable.GetRecords(whereClause2, new OrderBy(false, false), 0, 1);
System.Collections.Generic.IDictionary<string, object> vars = new System.Collections.Generic.Dictionary<string, object> ();
// if find a record, add it to the dropdown and set it as selected item
if (rc != null && rc.Length == 1)
{
string fvalue = ScopeTable.UOMID.Format(selectedValue);
ListItem item = new ListItem(fvalue, selectedValue);
item.Selected = true;
this.UOMID.Items.Add(item);
}
}
catch
{
}
}
}
示例4: PopulateSiteNameFilter
// Get the filters' data for SiteNameFilter.
protected virtual void PopulateSiteNameFilter(string selectedValue, int maxItems)
{
this.SiteNameFilter.Items.Clear();
// Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_SiteNameFilter function.
// It is better to customize the where clause there.
// Setup the WHERE clause,
WhereClause wc = this.CreateWhereClause_SiteNameFilter();
// Setup the static list items
OrderBy orderBy = new OrderBy(false, false);
orderBy.Add(VwSiteView.SiteName, OrderByItem.OrderDir.Asc);
string[] values = VwSiteView.GetValues(VwSiteView.SiteName, wc, orderBy, maxItems);
foreach (string itemValue in values)
{
// Create the item and add to the list.
string fvalue;
if ( VwSiteView.SiteName.IsColumnValueTypeBoolean()) {
fvalue = itemValue;
}else {
fvalue = VwSiteView.SiteName.Format(itemValue);
}
ListItem item = new ListItem(fvalue, itemValue);
this.SiteNameFilter.Items.Add(item);
}
// Set the selected value.
MiscUtils.SetSelectedValue(this.SiteNameFilter, selectedValue);
}