实体框架复杂类型VS创建新的实体

编程入门 行业动态 更新时间:2024-10-19 20:33:52
本文介绍了实体框架复杂类型VS创建新的实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在阅​​读实体框架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创建新的实体

本文发布于:2023-11-17 08:35:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609476.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   框架   类型

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!