c# - Group By using Select statement in Linq -


var query = in sfc.supplies_receivetrans              orderby i.poprctnm descending              select new { rr = i.poprctnm }; 

result:

rr-01, rr-01,  rr-02,  rr-02,  rr-02,  rr-test,  rr-test, 

how group rr in kind of statement

result:

rr-01, rr-02,  rr-test 

just few modification ask if possible 1 or have in mind? sorry asking interested in learning more on linq.. how convert string coz showing true or false.. boolean statement

var query = sfc.supplies_receivetrans.select(s => s.poprctnm.startswith(p)) .distinct() .orderby(p => p) .select(p => new { rr = p }) .take(10); 

you can use distinct or groupby methods in case

var query = sfc.supplies_receivetrans.select(s=> s.poprctnm)             .distinct()             .orderbydescending(p => p)             .select(p=> new { rr = p });   

if use orderbydescending result

rr-test  rr-02  rr-01  

but think want orderby result

rr-01  rr-02  rr-test  

so try below

var query = sfc.supplies_receivetrans.select(s=> s.poprctnm)             .distinct()             .orderby(p => p)             .select(p=> new { rr = p });  

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -