efcore
efcore copied to clipboard
[Feature] Interface mapping
Apart from having to request several tables (according to the used strategy), what is the real difficulty with this feature?
The absence of this functionality forces people to use abstract classes where an interface would have been desirable and sufficient, take the following example:
public class Feature {
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
public class Issue {
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public int Severity { get; set; }
}
public interface IFeatureProvider {
ICollection<Feature> Features { get; }
}
public interface IIssueProvider {
ICollection<Issue> Issues { get; }
}
public interface ICoffeeDrinker {
string FavoriteCoffe { get; }
}
public class EntityFrameworkUser : IFeatureProvider, IIssueProvider {
public EntityFrameworkUser() {
Issues = new Collection<Issue>();
Features = new Collection<Feature>();
}
public ICollection<Issue> Issues { get;}
public ICollection<Feature> Features { get; }
}
public class EntityFrameworkDeveloper : IFeatureProvider, ICoffeeDrinker {
public EntityFrameworkDeveloper() {
Features = new Collection<Feature>();
}
public ICollection<Feature> Features { get; }
public string FavoriteCoffe { get; }
}
public class FeatureProviderOwner {
public FeatureProviderOwner() {
FeatureProviders = new Collection<IFeatureProvider>();
}
public ICollection<IFeatureProvider> FeatureProviders { get; }
}
public class CoffeeDrinkerOwner {
public CoffeeDrinkerOwner() {
CoffeeDrinkers = new Collection<ICoffeeDrinker>();
}
public ICollection<ICoffeeDrinker> CoffeeDrinkers { get; }
}
The lack of this feature leads developers to create whimsical classes like "CoffeeDrinkerFeatureProvider"
Is there anything planned on this? For the Core 2.0 version? Any information on this topic is welcome.
Best regards, Florent.
@darkengines This is being tracked by #757. There isn't any fundamental difficulty here, although two things to consider:
- Make the resolution of concrete types flexible enough that it could be performed by an IoC container
- Ensure that polymorphic associations are allowed