实体框架将多个表映射到一个实体 [英] Entity Framework map multiple tables to one entity

查看:58
本文介绍了实体框架将多个表映射到一个实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,其中有一个用于活动订单的表和一个用于非活动订单的表。我想在Entity Framework中将此模型建模为一个称为Orders的实体。我还需要一种方法来确定此集合中的订单是否处于活动状态,最好是通过在实体上具有根据其所在表设置的status属性。总之可以使用Entity Framework 1来执行此操作。

I have a database with a table for active orders and one for inactive orders. I would like to model this in Entity Framework as one entity called Orders. I also need a way to determine if an order in this collection is active or not, preferably by having a status property on the entity that is set according to what table it is in. Is there anyway to do this using Entity Framework 1. What about in Entity Framework 4?

推荐答案

看看每个具体类型的表继承。

此处

Take a look at the Table Per Concrete Type inheritance.
It is described here in ADO.NET Team Blog.

这篇关于实体框架将多个表映射到一个实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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