는 다음 사항을 고려대해서 typeof와 기본 클래스
class Base
{
public int id { get; set; }
}
class Sub1 : Base
{
public int x { get; set; }
public int y { get; set; }
}
class Sub2 : Base
{
public string x { get; set; }
public string y { get; set; }
}
class Wrapper
{
public int x { get; set; }
public Sub1 sub1 { get; set; }
public Sub2 sub2 { get; set; }
}
내가 뭘하려고 다음, 난이 기능에서 CLR 형식
private static Dictionary<Type, SqlDbType> types;
public static SqlDbType GetSqlDbType(Type type, string propertyName)
{
if (types == null)
{
types = new Dictionary<Type, SqlDbType>();
types.Add(typeof(Int32), SqlDbType.Int);
types.Add(typeof(Int32?), SqlDbType.Int);
types.Add(typeof(decimal), SqlDbType.Decimal);
//etc
//the problem is here i want to return SqlDbType.VarBinary for every class that inherits Base
types.Add(typeof(Base), SqlDbType.VarBinary);
}
return types[type];
}
에서 SQL 유형을 얻기 위해이 유틸리티 기능이 있습니다 형식이 기본 클래스에서 상속 된 경우 SqlDbType.VarBinary를 반환하고 싶습니다. 이것이 가능합니까?
해보십시오 일지 어떨지를 할 수있다() – Liath