我想做这样的事情(大大简化的代码):
public class MyClass
{
private Type _listingType = typeof(AntiqueSellerListing);
public DeleteEntity(int id)
{
// This is what I would like to do, but it does not compile
SystemLogic.DeleteItem<this._listingType>(id);
// But this does
SystemLogic.DeleteItem<AntiqueSellerListing>(id);
}
}
DeleteItem 方法定义如下:
public void DeleteItem<T>(int primaryKeyValue) where T : class
我可能在这里遗漏了一些简单的东西,但我不确定如何做我想做的事。