Group by of a DataRow to return it to my DataSet

0

I have the following cycle so that each time I go through the DataRow add the value that touches more " :00 " and another equal with " :30 ", the topic is in which I repeat the values that I already have by default and I want to generate a group by to return the values I want only once:

for (int ii = 1; ii <= 24; ii++)
{
    DataRow dr = rs.Tables[0].NewRow();
    rs.Tables[0].Rows.Add((ii < 10 ? "0" : "") + ii.ToString() + ":00");
    rs.Tables[0].Rows.Add((ii < 10 ? "0" : "") + ii.ToString() + ":30");
    dr.AsEnumerable().GroupBy(row => row.Field<string>("Grupo")); 
}
    
asked by Cris Valdez 20.01.2017 в 22:11
source

1 answer

0

I think you lack details in the question, I can not understand it at all, but seeing your code would never work creating a DataRow in each iteration of the loop, much less returning the value also in each iteration, according to the general logic only the Add () methods of the Rows should be in the loop.
Honestly I'm not sure if I understood you, but try this:

DataRow dr = rs.Tables[0].NewRow();
for (int ii = 1; ii <= 24; ii++)
{
    rs.Tables[0].Rows.Add((ii < 10 ? "0" : "") + ii.ToString() + ":00");
    rs.Tables[0].Rows.Add((ii < 10 ? "0" : "") + ii.ToString() + ":30");
}
return dr.AsEnumerable().GroupBy(row => row.Field<string>("Grupo"));

If it is not what you are looking for then please try to add more details to your question, be more clear.

    
answered by 21.01.2017 в 01:03