我有那个界面:
public interface IEntityWithTypedId<T>{}
Run Code Online (Sandbox Code Playgroud)
并有两个类:
public abstract class EntityWithTypedId<TId> : IEntityWithTypedId<TId>{...}
public abstract class Entity : EntityWithTypedId<int>{...}
Run Code Online (Sandbox Code Playgroud)
所以我有这样的实体:
public class TestA : Entity
public class TestB : EntityWithTypedId<string>
public class TestC : EntityWithTypedId<byte>
Run Code Online (Sandbox Code Playgroud)
如何检查我的实体是否实现了IEntityWithTypedId?
谢谢
typeof(TestA).GetInterfaces()
.Any(i => i.GetGenericTypeDefinition() == typeof(IEntityWithTypedId<>))
Run Code Online (Sandbox Code Playgroud)