I have 3 tables as follows:
Users
Claims
UserClaims
I created the relationship between a user and his claims with the following code:
public class User
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
public ICollection<UserClaim> UserClaims { get; set; }
}
I would like to return an array of the Claims that a user has as well. Rather than just a list of their "subscriptions" to said claims.
How can I create a list of Claims (not UserClaims) for the user object. This way I can use User.Claims
rather than user.UserClaims
(which I know I will need for modifying, but not for basic claim testing).
Typing this on a tablet, so untested code, but you will need to use SelectMany for this. Something like...
jim.SelectMany(u => u.UserClaims.Select(uc => uc.Claim));
As I said, you'll need to check the exact syntax, but that should be close enough to get you going.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.