私は次のクラスを持っています:
public class POCOConfiguration : EntityTypeConfiguration<POCO>
{
public POCOConfiguration()
{
}
}
POCOConfiguration instance = new POCOConfiguration();
インスタンスPOCO
からタイプを取得するにはどうすればよいですか?
ありがとう
私は次のクラスを持っています:
public class POCOConfiguration : EntityTypeConfiguration<POCO>
{
public POCOConfiguration()
{
}
}
POCOConfiguration instance = new POCOConfiguration();
インスタンスPOCO
からタイプを取得するにはどうすればよいですか?
ありがとう
これをチェックして
POCOConfiguration instance = new POCOConfiguration();
Type t = instance.GetType().BaseType.GetGenericArguments()[0];
//here t is the type of POCO
動作します...
私があなたを正しく理解しているなら、あなたはPOCOのタイプを手に入れたいと思うでしょう。次に、メソッドを宣言し、次のように呼び出します。
public Type GetTypeOfPoco<T>(EntityTypeConfiguration<T> entityTypeConfiguration)
{
Type t = typeof(T);
return t;
}
あれを呼べ;
Type t = GetTypeOfPoco(instance);
それを見てください:http://msdn.microsoft.com/en-us/library/b8ytshk6.aspx
タイプを取得する方法を示す例があります (ステップ 3、4、および 5)。