asp.net - Fetch distinct record from dataset/table using linq to dataset/datatable -


i fetching record database , store result in dataset.

my dataset

sid table userid par1 par2 par3 274 tbl1  43     0    0    0 232 tbl1  43     1    2    0 232 tbl1  43     1    2    1 232 tbl2  43     1    2    0 232 tbl2  43     1    2    1 

i want show 6 column distinct record.distinct should on sid, table , userid.i want output this

sid table userid par1 par2 par3  274 tbl1  43     0    0    0  232 tbl1  43     1    2    0  232 tbl2  43     1    2    0 

does possible through linq dataset/datatable. unable asenumerable method on dataset getting on datatable.

i'm confused question want want?

yourdatatable.rows.cast<datarow>() .groupby(r => new { sid = r.field<int>("sid"), userid = r.field<int>("userid"), table = r.field<string>("table") }) .select(e => e.firstordefault()) .select(grp => new {     sid = grp.field<int>("sid"),     userid = grp.field<int>("userid"),     table = grp.field<string>("table"),     par1 = grp.field<int>("par1"),     par2 = grp.field<int>("par2"),     par3 = grp.field<int>("par3") }); 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -