Hi,
Please refer below code.
C#
List<Users> users = new List<Users>();
users.Add(new Users
{
Id = 1,
Type = "admin"
});
users.Add(new Users
{
Id = 2,
Type = "customer"
});
List<Transactions> transactions = new List<Transactions>();
transactions.Add(new Transactions
{
Id = 1,
UserId = 1,
Amount = 200
});
transactions.Add(new Transactions
{
Id = 2,
UserId = 2,
Amount = 200
});
transactions.Add(new Transactions
{
Id = 3,
UserId = 1,
Amount = 200
});
List<Transactions> customerTransactions = (from transaction in transactions
join user in users on transaction.UserId equals user.Id
where user.Id == 1
select transaction).ToList<Transactions>();
Transactions and Users Class
public class Transactions
{
public int Id { get; set; }
public int UserId { get; set; }
public int Amount { get; set; }
}
public class Users
{
public int Id { get; set; }
public string Type { get; set; }
}
I hope this will help you out.