本文整理汇总了C#中EntitySet.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# EntitySet.OrderBy方法的具体用法?C# EntitySet.OrderBy怎么用?C# EntitySet.OrderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntitySet
的用法示例。
在下文中一共展示了EntitySet.OrderBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitMyWorkspace
private void InitMyWorkspace()
{
myMenuEntitySet = this.MainEntitySet.Clone() as EntitySet<sysMenu>;
var root = myMenuEntitySet.AddNew();
root.Iden = -1;
root.ParentId = -2;
root.Name = "我收藏的菜单";
root.MenuOrder = -1;
MyFavoriteMenu.Query("SELECT a.Iden, a.MenuId,RowNumber FROM dbo.sysMyFavoriteMenu a with(nolock) WHERE UserId=:UserId", Session.UserInfo.UserId);
var list = this.MainEntitySet.Where(p => MyFavoriteMenu.Any(x => x.MenuId == p.Iden));
foreach (var item in list)
{
var obj = myMenuEntitySet.AddNew();
obj.Copy(item);
obj.ParentId = root.Iden;
obj.MenuOrder = MyFavoriteMenu.First(p => p.MenuId == item.Iden).RowNumber;
obj.MenuType = (int)sysMenuType.Menu;
}
this.treeMyMenu.OptionsBehavior.AutoPopulateColumns = false;
this.treeMyMenu.OptionsBehavior.Editable = false;
if (this.treeMyMenu.Columns.ColumnByFieldName("Name") == null)
{
var colName = this.treeMyMenu.Columns.Add();
colName.Caption = "名称";
colName.FieldName = "Name";
colName.Name = "colName";
colName.OptionsColumn.AllowEdit = false;
colName.OptionsColumn.AllowMove = false;
colName.OptionsColumn.AllowMoveToCustomizationForm = false;
colName.OptionsColumn.AllowSort = false;
colName.OptionsColumn.ReadOnly = true;
colName.OptionsColumn.ShowInCustomizationForm = false;
colName.OptionsColumn.ShowInExpressionEditor = false;
colName.OptionsFilter.AllowAutoFilter = false;
colName.OptionsFilter.AllowFilter = false;
colName.Visible = true;
colName.VisibleIndex = 0;
}
var source = myMenuEntitySet.OrderBy(p => p.ParentId).OrderBy(p => p.MenuOrder).OrderBy(p => p.Iden);
this.treeMyMenu.DataSource = new BindingSource() { DataSource = source.Select(p => p.DataRowView) };
this.treeMyMenu.KeyFieldName = "Iden";
this.treeMyMenu.ParentFieldName = "ParentId";
this.treeMyMenu.ExpandAll();
}