I am using Entity Framework 4 CTP5 Code First, and I have a model line by line:
public class User {
public int UserId { get; set; }
public string Email { get; set; }
public ICollection<Customer> TaggedCustomers { get; set; }
}
public class Customer {
public int CustomerId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public ICollection<User> TaggedBy { get; set; }
}
There are many, many relationships in which the User can “tag” a client and a client that can be “tagged” by many users. I have a working DbContext and I can request clients using
var customers = DbContext.Customers.Include(c => c.TaggedBy);
But each client will have all the users who tagged the client. How to limit the TaggedBy collection to just the result using the specified UserId?
I tried the lines DbContext.Customers.Include(c => c.TaggedBy.Select(x => x.Id == userId));, but this causes an error.
source
share