I have a c# data class defined with an inheritance chain that looks like this:
public abstract class EntityBaseCore
public abstract class EntityBase : EntityBaseCore
public partial class AdmSite : EntityBase
And a generic class defined like this:
public abstract class ViewModelSecurityBase<T> : Screen, where T : EntityBaseCore
public abstract class EditorViewModelBase<T> : ViewModelSecurityBase<T> where T : EntityBaseCore
My view model class looks like this:
public class SiteViewModel : EditorViewModelBase<AdmSite>
This fails with
The type 'Yargo.DataModel.AdmSite' cannot be used as type parameter 'T' in the generic type or method 'Yargo.Common.ViewModel.EditorViewModelBase'. There is no implicit reference conversion from 'Yargo.DataModel.AdmSite' to 'Yargo.DataModel.EntityBaseCore'
The inheritance chain between AdmSite and EntityBaseCode seems direct. I don’t understand why this is failing.
The following code seems to work for me.