我有一个通用的方法
bool DoesEntityExist<T>(Guid guid, ITransaction transaction) where T : IGloballyIdentifiable;
Run Code Online (Sandbox Code Playgroud)
如何以下列方式使用该方法:
Type t = entity.GetType();
DoesEntityExist<t>(entityGuid, transaction);
Run Code Online (Sandbox Code Playgroud)
我一直收到愚蠢的编译错误:
找不到类型或命名空间名称't'(您是否缺少using指令或程序集引用?)
DoesEntityExist<MyType>(entityGuid, transaction);
Run Code Online (Sandbox Code Playgroud)
完美的工作,但我不想使用if指令每次调用具有单独类型名称的方法.