0

I have done research on how to delete rows from a datatable.

Dataset.Datatable.Rows(0).Delete()

The problem I am having now is I need to delete specific data from my linq query.

 Dim qy = From rows In loadedData
 Where rows.Field(Of Double)("count") = elem
 Take elem
 Select ("count")

What I need to do is Delete the rows that are in the result of this linq query.

"Delete top elem from loaded data where count = elem"

I am just not sure how to write that in vb.net since my research shows you can't manipulate data using a linq query, you can only select it.

Oh and the reason I have the select top elem, is because the elem can be duplicated, so I could have a count of 500 rows and 500 rows. So I am using this query to get the first 500 rows and then delete that so when I run the query again I am not getting duplicate data.

Any help would be appreciated.

4

1 回答 1

1
Dim toDelete = From row In table
               Let count = row.Field(Of Double)("count")
               Where count = elem
               Select row
               Take elem

For Each row As DataRow in toDelete 
    row.Delete()
Next
于 2013-10-15T14:22:40.913 回答