The method is this one, EntityBase.Get:
public class EntityBase
{
public int Id;
public static T Get<T>(int id) where T : EntityBase
{
DataContextExtender extender = new DataContextExtender();
return extender.DataContext.GetTable<T>().Where(t => t.Id == id).FirstOrDefault();
}
}
How I want to use it:
Event ev = Event.Get(EventId)
, where Event inherits EntityBase.
The method compiles by itself, like it is, but I get an error message if I want to use it that way:
The type arguments for method 'RiotingBits.Data.Entities.EntityBase.Get(int)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
I know I can use it like Event.Get<Event>(EventId)
, but I really want to use it 'my way'. The code for the method doesn't matter, I suspect there might be a way to hint the method how to infere the right type.