linq to sql和继承问题
有谁知道如何获取特定类型的继承代码(Linq to sql 中的单表继承)?
当我创建一个新的实体B(继承自A)时,我想在A中编写一些代码,这对于从A继承的所有对象都有效。
但是,当您创建一个新的实体B时,它的继承代码不是还填了。 有没有什么方法可以根据类型获取继承代码? 我知道 Table 类中有一个 metaTable 属性,但它是私有的,并且该类是密封的。
Does anyone know how to to get the inheritance code for a specific type (single table inheritance in Linq to sql) ?
When I create a new entity B (which is inherited from A), I would like to write some code in A, that is valid for all objects inherited from A.
However, when you create a new entity B, it's inheritance code is not yet filled in.
Is there any method to get the inheritance code based upon the type?
I know there is a metaTable property in the Table class, but it's private and the class is sealed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于找到了:
int继承代码= (int)DataContext.Mapping.GetMetaType(instance.GetType()).InheritanceCode;
finally found it :
int inheritanceCode= (int)DataContext.Mapping.GetMetaType(instance.GetType()).InheritanceCode;