I have a base class Dialog:
public class Dialog<T> : IDialogAble<T> where T : class, IEntity
{
public IEntityService<T, int> Service { get; set; }
public async Task Suchen(Expression<Func<T, bool>> criteria)
{
Cursor = Cursors.Wait;
await Service.Search(criterian);
Cursor = Cursors.Arrow;
}
}
In this class I have a Service which is used in the base class and the derived class. I set the Service in the constructor:
Service = serviceFactory.CreateEntityService<MyObject, int>(context);
Now I have a object where my Service have to implement short not int because the primary key on the database is tinyint. So like this:
Service = serviceFactory.CreateEntityService<MyObject, short>(context);
But this doesn't work because short isn't convertible to int in this situation. The Problem is, that Dialog<T>
cannot change to Dialog<T, TKey>
.
I tried with the new modifier, but this isn't work because I use the service in the base class:
public new IEntityService<OtherObject, short> Service { get; set; }
I don't find a solution for this, maybe someone has a idea.