小编Ric*_*ich的帖子

从实体框架代理获取底层实体对象

从一个实体获得它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)

c# entity-framework

38
推荐指数
3
解决办法
3万
查看次数

在 Typescript 中获取泛型类型的内部类型

如何在 Typescript 中获取泛型类型的内部类型?那么TmyType<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)

谢谢

typescript

5
推荐指数
1
解决办法
1689
查看次数

标签 统计

c# ×1

entity-framework ×1

typescript ×1