Question: I have a list of objects like:

```
var list = new List<someUi>
            {
               {Name="Arjun", Salary=100, Div="A"},
               {Name="Dani", Salary=50, Div="B"},
               {Name="Nick", Salary=75, Div="C"},
               {Name="Arjun", Salary=55, Div="A"},
               {Name="Dani", Salary=10, Div="B"}
            }

```

Now I want to merge the list based one **Name** `(GroupBy Name)` and want to total the Salary.

so, My expected output is like this:

```
var list = new List<someUi>
            {
               {Name="Arjun", Salary=155, Div="A"},
               {Name="Dani", Salary=60, Div="B"},
               {Name="Nick", Salary=75, Div="C"}
            }

```

How can I do that using C# or LINQ.

Thanks in advance.

Answer: 
I would phrase this using exists logic:

```sql
SELECT MarketID, EmployeeID
FROM Table1 t1
WHERE NOT EXISTS (SELECT 1 FROM Table2 t2
                  WHERE t2.MarketID = t1.MarketID AND
                        t2.EmployeeID = t1.EmployeeID);

```
Simply use **EXCEPT** for this use case like below.

```
SELECT MarketID, EmployeeID
FROM Table1
EXCEPT
SELECT MarketID, EmployeeID
FROM Table2;

```

If you interested to look on other alternatives, Please visit this Stackoverflow post where I have covered 10 other alternatives for the same - [An alternative for "NOT IN" in SQL SERVER](https://stackoverflow.com/questions/30614196/an-alternative-for-not-in-in-sql-server/59789254#59789254)