In the scenario I have to delete specific row but there is an condition like column name is (customer names) are and there is an column name is {Match Type} But there value is fixed ( Probable, Confirmed) so I have to remove those rows like
Which all Match types are probably only so in below example suraj name that dats should be delete only Vikram data I need bcz Vikram data are all probable and in suraj there is on confirmed so I want to delete that data
Cust name match type
1)Suraj probable
2)Suraj. Probable
3)Suraj Confirmed
4)Suraj. Probable
5)Vikram Probable
6)Vikram Probable
This LINQ query filters the rows in the DataTable dt to include only those with a “Match Type” equal to “Probable” and creates a new DataTable with the filtered rows. The original DataTable will now contain only the rows that match your criteria.
I have to remove all confirmed case but there is scenario for example 10 cases is there those 10 cases are probable but one case is confirmed so I want to delete those all 10 rows.
2 condition of the all 10 cases is probable that data I want and it’s true condition
Use the Read Range activity to read the Excel file into a DataTable.
Create a Filtered DataTable:
Use a For Each Row activity to loop through each row in the DataTable.
Within the loop, create a variable to store the “Cust name” value of the current row.
Create a Boolean variable to keep track of whether you should remove the current row.
Create another loop to iterate through all rows with the same “Cust name” as the current row.
Inside this second loop, check if the “Match Type” of each row with the same “Cust name” is “Confirmed.” If you find any “Confirmed” Match Type, set removeRow to True.
After the second loop, check the removeRow variable. If it’s True, use the Remove Data Row activity to remove the current row from the DataTable.
(From d in YourOriginDataTableVar.asEnumerable
Group d by k("Customer Name").toString.ToUpper.Trim into grp=Group
Let chk = grp.any(Function (g) g("Match Type").toString.ToUpper.Trim.Equals("CONFIRMED"))
Where Not chk
From gm in grp
Select r = gm).CopyToDataTable