>我有一个按单个条目分组的跳转列表,但我想按字母对列表进行分组
var ANBA = from accountsTable in dataSource
orderby accountsTable.Extra
group accountsTable by accountsTable.Extra.Substring(0, 1) into c
orderby c.Key
select new Group<AccountsTable>(c.Key, c);
this.AccountsList2.ItemsSource = ANBA;
此代码使列表与小写字母和大写字母与不同的组
a
ab
ac
ad
A
Aa
Ab
Ac
如何使小写字母和大写字母在同一组中,以及单个组中的所有其他字符,就像所有数字和字符一样
a
Aa
ab
ad
AGDS
*
1
5000
@@ASD
下面介绍如何修改查询以执行此操作:
List<Table> Source = new List<Table>();
var ANBA = from accountsTable in Source
orderby table.Extra
group table by (( table.Extra[0]>='a' &&table.Extra[0]<='z' )
||( table.Extra[0]>='A' &&table.Extra[0]<='Z' ) ?table.Extra.Substring(0,1).ToUpper()[0]:'*') into c
orderby c.Key
select new Group<Table>(c.Key.ToString(), c);
this.ANListGropus.ItemsSource = ANBA;