0

I've a datatable that has been filled by excel sheet, it has lots of product id's and some other data. I want to check if there is any duplicate product id in my datatable and tell user that these prodcuts ids are duplicates or something like that.

Lmbda, Linq , Looping anything will do.

Thanks

1

1 Answer 1

3

Here's a slightly modified version of another answer C# Linq finding duplicate row:

var qry =  from p in Products
           group p by p.productID into grp
           where grp.Count() > 1
           select grp;

foreach (var product in qry)
{
    // Do something as needed/desired
}

Products is the DataTable, productID is the product ID; substitute appropriate names from your code as needed. I haven't tested this, but it should at least get you pointed in the right direction.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.