Reputation: 2610
class UserInfo
{
public int UserId { get; set; }
public string DisplayName { get; set; }
public DateTime CreationTime { get; set; }
public DateTime LastModified { get; set; }
}
class UserProfile : public UserInfo
{
// I don't want this to be directly exposed out of the DAL
public string ConfirmationToken { get; set; }
// Navigation property
public virtual ICollection<UserVariant> Variants { get; set; }
}
class DAL
{
// Returned value include no navigation properties
public UserInfo GetUser(int UserId) { ... }
}
Is it possible to define inheritance @ the '.edmx' in such a way that 'UserProfile' will be used as the reference for the DB table rather than UserInfo ?
Upvotes: 1
Views: 149
Reputation: 2610
Solution was to convert 'Model-First' to 'Code-First' and have the DB Model class inherit from an interface exposing the selected methods ( non navigation attributes ), this interface would then get exposed by the DAL avoiding out-of-context Navigation attr access.
Unfortunately, I didn't find a Model-First solution for the above mentioned problem and had to go Code-First .
Upvotes: 1