I have a class:
public class CustomerEmailAlert
{
public string EmailId { get; set; }
public string Interest1 {get;set;}
public string Interest2 {get;set;}
}
The result from sql is something like this:
+---------------+-----------+-----------+
| Email | Interest1 | Interest2 |
+---------------+-----------+-----------+
| abc@gmail.com | Burrito | Apple |
| abc@gmail.com | Pizza | Milk |
| abc@gmail.com | Apple | Burrito |
| def@gmail.com | Milk | Banana |
+---------------+-----------+-----------+
I have mapped the result using Dapper
to List<CustomerEmailAlert>
List<CustomerEmailAlert>= con.Query<CustomerEmailAlert>("getalerts", commandType: CommandType.StoredProcedure).ToList();
My question is: How do I group Customers by Email so that the email they receive contains their interests (they should receive only 1 copy of email)
I have tried this: Group by in LINQ