I'm having trouble instantiating the service. It is generic and I need it like this, since I can use any entity in it. When I start the service in hibernate, I need to pass the entity I'm going to work to use the bank mapping. That is, when you instantiate the service by passing DocumentDocument or Document, it uses the DocumentData or Document entity mapping. I'm just going to use methods and properties of the parent entity, I just need to use the child class to access the mapping of the right table I'm going to search. in normal screen, I override the methods passing the entity that I need, but in the search screen, I need to do everything on the same screen, because it is not possible to make a screen for each search
Can not implicitly convert type 'MasterCastServ' to 'ServiceCadastro'
public class TipoDocumento : CadastroMestre
{
}
public class ServicoCadastroMestre<T> : ServicoCadastro<T> where T : CadastroMestre
{
}
public abstract class ViewCadastroMestre<T> : ViewCadastro<T> where T : CadastroMestre
{
public abstract ServicoCadastro<T> GetServico();
public abstract T GetEntidade();
}
public class ViewPesquisa : ViewCadastroMestre<CadastroMestre>
{
public override CadastroMestre GetEntidade()
{
return new TipoDocumento();
}
////o problema está aqui
public override ServicoCadastro<CadastroMestre> GetServico()
{
return new ServicoCadastroMestre<TipoDocumento>();
}
}
///////aqui funciona normalmente///////
public class ViewTipoDocumento : ViewCadastroMestre<TipoDocumento>
{
public override TipoDocumento GetEntidade()
{
return new TipoDocumento();
}
public override ServicoCadastro<TipoDocumento> GetServico()
{
return new ServicoCadastroMestre<TipoDocumento>();
}
}