I have the following model
Deal.cs
public Guid Id { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public double? Price { get; set; }
public Guid UserId { get; set; }
public User User { get; set; }
User.cs
public Guid Id { get; set; }
public string Name { get; set; }
public string ResumptionCookie { get; set; }
public List<Deal> Deals { get; set; }
I'm trying to get all users who currently have a deal with a specific code. I could do a get all users and write a big LINQ query but there must a more elegant way.
I read the documentation but it's not quite what I'm looking for and I haven't been able to figure it out.
you can try filtering on the deals first then selecting the user
db.Deals.Where(x=>x.code == "specified code").Select(x=>x.User)
assuming that each user has the deal with "specified code" once if not use .Distenct() or what Akash KC suggested in the comments