从一个实体获得它DbEntityEntry.Entity
.这将返回实体的Entity Framework代理.
如何访问基础对象,因为它是原始类型而不是代理?
或者,我需要动态尝试将代理转换为实体类型.这是一个开始......
var theEntityType = entityEntry.Entity;
if (theEntityType.BaseType != null && entityType.Namespace == "System.Data.Entity.DynamicProxies")
theEntityType = entityType.BaseType;
// Now I need to cast to the correct type
var entityObject = (theEntityType)entityEntry.Entity; // THIS WON'T WORK BECAUSE `theEntityType` is dynamic.
// My entites also don't implement IConvertible
Run Code Online (Sandbox Code Playgroud) 如何在 Typescript 中获取泛型类型的内部类型?那么T
的myType<T>
?
例如:
export class MyClass {
myMethod(): Observable<{ prop1: string, ... }> {
....
}
}
type myClassReturn = ReturnType<MyClass['myMethod']>;
// Sets the type to 'Observable<{ prop1: string, ... }>'.
// How do I set this to just '{ prop1: string, ... }'?
Run Code Online (Sandbox Code Playgroud)
谢谢