I have a table with some fields, it is not easy to describe my issue but, I want to group table by a src field which is have select distinct on dst field.
Table name is F has src, name, dst, time fields.
I want my query by linq is resulted as below:
src dst src dst
1 a
1 c 1 a,c
1 a ====>> 2 b
2 b 3 c
3 c
I want for every src the dst are put in list.
this code gives an error.
List srcaddress = (from DataRow dr in dt.Rows group dr by dr["dst"].ToString() Select new dr["src"]).ToList();
Abhishek JainPosted Sep 6, 2013, 8:19 AM
For every src if the count if dst is greater than 0 then what you want is that the comma separated dst should be put into variable, but if there are like to src having 2 dst each then will you create two variables, if so you can do something like this:
dstCount = rowsGroup.Select(av => av["dst"].ToString()).Distinct().Count()
Now you have bith the count and the comma separated list of dst for each src, you can do anything with this list by making a for loop or foreach loop of linq.
And You can try something like this:
Hope it helps..
Regards
AJ
diamond diamondPosted Sep 6, 2013, 9:07 AM
Just let me know, in src variable save index or string of values?
because my values in src are string .
If I want to say if the src whoes more than 2 dst put in srcaddress list
diamond diamondPosted Sep 6, 2013, 7:40 AM
I need to list of string of dst too, but I couldn't put the srcaddress list.
I want to say if every src has more than t dst put it a variable.
Let me know how can I do?
Abhishek JainPosted Sep 6, 2013, 7:33 AM
Abhishek JainPosted Sep 6, 2013, 7:31 AM
Regards
AJ
diamond diamondPosted Sep 6, 2013, 7:27 AM
It gives an error :
I want to put condition if the count of dst of every src is more than t, add 1 to matrix.
Abhishek JainPosted Sep 6, 2013, 6:19 AM