Datatable LINQ select datarow only returning one row and how to order

user222427

I have a datatable with 4 columns

 - A|1|Apple|Turnip
 - A|2|Water|Fruit
 - B|1|Water|Orange
 - B|2|Water|Mango
 - C|1|Hello|World

What I want to do is select distinct column A. Then I want to select distinct columns 2,3,4 based on column A.

This is what i'm using to select distinct column A. My question with this first part is how do you order by column A (linkControl). Member is my datatable, and this returns every distrinct column a

    var linkControl = Member.AsEnumerable()
                            .Select(row => new
                            {
                                linkCon = row.Field<string>("LinkControl")
                            })
                            .Distinct();

Then because I want to iterate each of the linkCons I do the following, which only returns one datarow even though there is about 20 datarows for each linkCon. How do i return all the rows?

 foreach (var linkC in linkControl)
    {
var linkControllink = (from DataRow dr in ADMemberships.Rows
                               where dr["LinkControl"] == linkC.linkCon
                               orderby (string)dr["URLDescription"]
                               select dr);

}


        foreach (var lcl in linkControllink)
        {
                //only has one row in it
         }
user222427

I had to change the code to where dr["LinkControl"].ToString() == linkC.linkCon.ToString() and i dont really understand why.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

select case in Datatable datarow in Linq

From Dev

LinQ query select DataRow from DataTable

From Dev

LinQ returning no datarow error

From Dev

b:dataTable select a single row (and only a single one)

From Dev

MySQL Select only returning one row from eclipse

From Dev

Using linq to group, select, and order a datatable

From Dev

how to loop through each row of datatable in order to execute a function one by one for each row

From Dev

Select columns for ORDER BY only, not returning them in the results

From Dev

mysql select one row if no row found with an order

From Dev

mysql select one row if no row found with an order

From Dev

crystal report only show one row of datatable

From Dev

Primefaces datatable combine data in only one row

From Dev

How to select only one column to return an object in linq

From Dev

MyBatis ResultMap Collection - Returning only one row

From Dev

Query only returning one row (PHP / MYSQL)

From Dev

mysql subquery only returning one row

From Dev

MyBatis ResultMap Collection - Returning only one row

From Dev

MySQL cursor is returning only one row

From Dev

sql query returning only one row

From Dev

how to select only one row from all columns but the first

From Dev

MySQL - How to select only two columns from a row in one table

From Dev

C# Linq How to select the distinct row count of multiple columns in a datatable

From Dev

C# Linq How to select the distinct row count of multiple columns in a datatable

From Dev

Insert datarow from one datatable to a particular index

From Dev

Datatable row is cutted in half when there is only one row in the table

From Dev

Datatable row is cutted in half when there is only one row in the table

From Dev

Select one existing row order by where clause

From Dev

DataTable Select not returning values

From Dev

MySQL returning only one row (most recent one)

Related Related

  1. 1

    select case in Datatable datarow in Linq

  2. 2

    LinQ query select DataRow from DataTable

  3. 3

    LinQ returning no datarow error

  4. 4

    b:dataTable select a single row (and only a single one)

  5. 5

    MySQL Select only returning one row from eclipse

  6. 6

    Using linq to group, select, and order a datatable

  7. 7

    how to loop through each row of datatable in order to execute a function one by one for each row

  8. 8

    Select columns for ORDER BY only, not returning them in the results

  9. 9

    mysql select one row if no row found with an order

  10. 10

    mysql select one row if no row found with an order

  11. 11

    crystal report only show one row of datatable

  12. 12

    Primefaces datatable combine data in only one row

  13. 13

    How to select only one column to return an object in linq

  14. 14

    MyBatis ResultMap Collection - Returning only one row

  15. 15

    Query only returning one row (PHP / MYSQL)

  16. 16

    mysql subquery only returning one row

  17. 17

    MyBatis ResultMap Collection - Returning only one row

  18. 18

    MySQL cursor is returning only one row

  19. 19

    sql query returning only one row

  20. 20

    how to select only one row from all columns but the first

  21. 21

    MySQL - How to select only two columns from a row in one table

  22. 22

    C# Linq How to select the distinct row count of multiple columns in a datatable

  23. 23

    C# Linq How to select the distinct row count of multiple columns in a datatable

  24. 24

    Insert datarow from one datatable to a particular index

  25. 25

    Datatable row is cutted in half when there is only one row in the table

  26. 26

    Datatable row is cutted in half when there is only one row in the table

  27. 27

    Select one existing row order by where clause

  28. 28

    DataTable Select not returning values

  29. 29

    MySQL returning only one row (most recent one)

HotTag

Archive