Entity framework EF6-在DbCommandTreeInterceptor中获取DbUpdateCommandTree的实体
我试图在截取DbUpdateCommand树时获取实体/类的“NotMapped”属性的值 我已经查看了各种元数据,但是我无法从CommandTree中找到实体的“链接”,所以不幸的是我被卡住了 有可能吗Entity framework EF6-在DbCommandTreeInterceptor中获取DbUpdateCommandTree的实体,entity-framework,entity-framework-6,interceptor,Entity Framework,Entity Framework 6,Interceptor,我试图在截取DbUpdateCommand树时获取实体/类的“NotMapped”属性的值 我已经查看了各种元数据,但是我无法从CommandTree中找到实体的“链接”,所以不幸的是我被卡住了 有可能吗 public class SomeEntity { public int ID { get; set; } [NotMapped] public int SomeUnmappedProperty { get; set; } } public class Comman
public class SomeEntity
{
public int ID { get; set; }
[NotMapped]
public int SomeUnmappedProperty { get; set; }
}
public class CommandTreeInterceptor : IDbCommandTreeInterceptor
{
public void TreeCreated(DbCommandTreeInterceptionContext ctx)
{
if (ctx.OriginalResult.DataSpace == DataSpace.SSpace)
{
var updateCommand = ctx.OriginalResult as DbUpdateCommandTree;
if (updateCommand != null)
{
// I would like to get a value of a specific property here.
// Pseudo code
var val = updateCommand.Entity.GetPropertyValue("SomeUnmappedProperty") as int;
}
}
}
}