I have two Datatables in my C# Windows Forms application;

```
DataTable dtProduct;
DataTable dtDetails;

```

`dtProduct` is being populated from `MS Access` and `dtDetails` is from `MySql`, those have following like records

**dtProduct**

```
code   | pNameOrignal
----------------------
101    | product one
220    | product two 
65     | product three
104    | product four
221    | product five 
654    | product six

```

**dtDetails**

```
id | tid | code | pNameLocal        | qty | price
-------------------------------------------------
1  |101  | 101  | some_local_name   | 2   |20.36
2  |102  | 202  | some_local_name   | 1   |15.30 // same entry as same tid and all same 
3  |102  | 202  | some_local_name   | 1   |15.30 //same entry as same tid and all same
4  |102  | 202  | some_local_name   | 1   |10.00 //same entry as same tid but price is different
5  |102  | 202  | some_local_name   | 2   |15.30 //same entry as same tid but different qty
6  |102  | 202  | some_local_name2  | 1   |15.30 //same entry as same tid but pNameLocal different
7  |103  | 202  | some_local_name   | 1   |15.30 // different entry of same product see different tid
8  |104  | 65   | some_local_name   | 5   |05.00
9  |105  | 700  | some_local_name   | 2   |07.01 // does not exist in "dtProduct"

```

I am currently looping through all records of `dtdetails` with `dtProduct` to replace original name of product `pNameOrignal` from `dtProduct` on basis of uniqueness of `code` column in both tables. my existing code look like this;

```
dtDetails.Rows
    .Cast<DataRow>()
    .Join
    (
        dtProduct.Rows.Cast<DataRow>(),
        r1 => new { p1 = r1["code"], p2 = r1["code"] },
        r2 => new { p1 = r2["code"], p2 = r2["code"] },
        (r1, r2) => new { r1, r2 }
    )
    .ToList()
    .ForEach(o => o.r1.SetField("pNameLocal", o.r2["pNameOrignal"]));

```

**What is now required**

1. need to merge or make one row for same entries with **same tid and all same** to single row by making **qty to 2 (as in current records)** by adding both and **price to 30.60 (as in current records)**

**Explanation:** multiple records which are exactly same (duplicates) merged as one row by retaining their qty and price as per number of records.
2. entry against **tid = 105** which has `code = 700` does not exist in `dtProduct`, it will not replace `pOrignalName` from there, will keep same name as currently my code do, I need to add or concatenate "NotFound" with that name.