每个层次结构映射的动态表 [英] Dynamic Table Per Hierarchy Mapping

查看:78
本文介绍了每个层次结构映射的动态表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么而不是这个


< span style ="font-size:xx-small"> modelBuilder.Entity< Product >()


  ;&NBSP;&NBSP; .Map< 产品>(m => m.Requires(" Type" ) .HasValue("Current" ))


    .Map< DiscontinuedProduct >(m => m.Requires(" Type" ) .HasValue(" Old" ));

modelBuilder.Entity<Product>()
    .Map<Product>(m => m.Requires("Type").HasValue("Current"))
    .Map<DiscontinuedProduct>(m => m.Requires("Type").HasValue("Old"));

我可以只需映射基本类型并有一列来存储  AssemblyQualifiedName 当我执行查询时,我会收到实例化的正确类型?

I Could just Map the base type and have a column to store the AssemblyQualifiedName and when I do the query I receive the correct types instantiated?

 

推荐答案

Hi Luiz,

Hi Luiz,

这是Code First默认执行的操作,如果你想要,你只需编写上面的代码可以更好地控制使用的值或列的调用内容。 (Code First将只使用普通的类名而不是完全限定的名称)

That is what Code First does by default, you only need to write the above code if you want to have more control over what values are used or what the column is called. (Code First will just use the normal class name rather than fully qualified name though)

~Rowan


这篇关于每个层次结构映射的动态表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆