0

I have a jump list which groups by individual entries but i wanted to group list by alphabets

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;

this code makes list with small letter & capital letter with different group

a
    ab
    ac
    ad
A
    Aa
    Ab
    Ac

How to make it where small letter & capital letter will be in same group & all the other characters in single group like all the numbers & characters

a 
    Aa
    ab
    ad
    AGDS
*
    1
    5000
    @@ASD
4

1 回答 1

1

以下是如何修改查询来做到这一点:

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;
于 2013-09-14T23:25:29.857 回答