我在阅读实体框架4.0,我想知道我为什么要创建一个复杂类型,而不是一个新的实体(表)以及它们之间的关系?
I'm reading about the Entity Framework 4.0 and I was wondering why should I create a complex type and not a new Entity (Table) and a relation between them?
推荐答案最好的例子是一个地址。使用复杂的类型为一个地址要容易得多,比一个新的实体来处理。对于复杂的类型,你不必处理主键。想想访问地址是如何实体的许多常见的类型将有一个地址(企业单位,人员,地点)。想象一下,填充许多人的地址和需要设置一个关键点为每一个。对于复杂的类型,你只需访问内部性能,它们类型就大功告成了。这里是一个例子的MSDN链接。 msdn.microsoft/en-us/library/bb738613.aspx
The perfect example is an address. Using a complex type for an address is much easier to deal with than a new entity. With complex types you do not have to deal with the Primary Key. Think about accessing an address how many common types of entities would have an address (Business Units, People, Places). Imagine populating many peoples addresses and needing to set a key for each one. With complex types you simply access the internal properties of they type and you're done. Here is an MSDN link of an example. msdn.microsoft/en-us/library/bb738613.aspx
更多推荐
实体框架复杂类型VS创建新的实体
发布评论