on-internet
← Community

Entity Framework, not mapped property in query

Stack Overflow ·

I'm creating an entity model in which I want to put a not mapped properties. These properties are there to simplify access to values from relationship. Model shown is just a simple example. In users_roles entity, named UserRole, I want to have UserName property and RoleName. public class UserRole { public int Id { get; set; } public int IdUser { get; set; } public int IdRole { get; set; } public User User { get; set; } public Role Role { get; set; } [NotMapped] public string UserName { get { return User.Name; } } [NotMapped] public string RoleName { get { return Role.Name; } } } It's important

Comments

Sign in or sign up to comment and upvote.

No comments yet.