可以使用实体框架4 CTP5访问TPH映射中的鉴别器值 [英] Can I access the discriminator value in TPH mapping with Entity Framework 4 CTP5
问题描述
使用实体框架4 CTP5代码首先和这个例子
Using Entity Framework 4 CTP5 Code First and this example
是否可以访问鉴别器值?
Is it possible to access the discriminator value?
我想在投影中使用它,如
I would like to use it in a projection like
context.BillingDetails.Select(x => new { Number = x.Number, DiscrimitatorValue = /* how do I get the discriminator value? */ });
从这篇文章我明白鉴别器不能映射到一个属性,但有没有其他方式访问? / p>
From this post I understand the discriminator cannot be mapped to a property but is there any other way of accessing it?
推荐答案
从 Morteza Manavi在他的评论中发布简单的答案是否
你应该知道,鉴别器列是由Code First内部使用的,你不能读取/ /从继承映射的角度来写它的值。
you should be aware that the discriminator column is used internally by Code First and you cannnot read/write its values from an inheritance mapping standpoint.
要访问鉴别器,我必须执行一个 SqlQuery
对数据库或更改我的映射st策略。
To access the discriminator I would have to execute a SqlQuery
against the database or change my mapping strategy.
这篇关于可以使用实体框架4 CTP5访问TPH映射中的鉴别器值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!