Entity Framework class 的 DynamicProxies 长度名称
Entity Framework DynamicProxies length name of class
我有存储库并尝试从库中获取对象。但是,类型 class:
System.Data.Entity.DynamicProxies.FoundationInformatio_2B2257689287A8D593FBF2013945969F4E7612CD66850A8D4A6D6CAAC5BFF101
我的 class 类型为:FoundationInformation
我需要全名。为什么 class 的名称长度在 DynamicProxies 中是 20 个字符?如何获取class的全名?
我决定:
ObjectContext.GetObjectType(obj.GetType());
您可以尝试一些扩展方法:
public static Type GetNonProxiedType(this object obj)
{
return obj.GetType().GetNonProxiedType();
}
public static Type GetNonProxiedType(this Type type)
{
return IsProxied(type) ? type.BaseType : type;
}
public static bool IsProxied(this Type type)
{
return type.Namespace.Contains("Proxies");
}
那么你只需编码 entity.GetNonProxiedType().FullName
希望有用。
我有存储库并尝试从库中获取对象。但是,类型 class:
System.Data.Entity.DynamicProxies.FoundationInformatio_2B2257689287A8D593FBF2013945969F4E7612CD66850A8D4A6D6CAAC5BFF101
我的 class 类型为:FoundationInformation
我需要全名。为什么 class 的名称长度在 DynamicProxies 中是 20 个字符?如何获取class的全名?
我决定:
ObjectContext.GetObjectType(obj.GetType());
您可以尝试一些扩展方法:
public static Type GetNonProxiedType(this object obj)
{
return obj.GetType().GetNonProxiedType();
}
public static Type GetNonProxiedType(this Type type)
{
return IsProxied(type) ? type.BaseType : type;
}
public static bool IsProxied(this Type type)
{
return type.Namespace.Contains("Proxies");
}
那么你只需编码 entity.GetNonProxiedType().FullName
希望有用。