返回“定制” LinqToEntitiesDomainService 中的实体而不将它们映射到数据库?
(我搜索了很多,但还没有找到答案,也许根本不可能:/)
是否可以在 EDM 中创建根本不映射到任何数据库的实体(我从中生成了 DomainService) ,只是在 DomainService 和 Client 之间使用? 对于那些实体框架专家来说,这可能听起来很奇怪:)我的目标是使得可以仅返回实体的几个属性,而不是整个实体。 例如,我只需要用户的姓名和生日,而不关心其他 10-20 个属性。在这种情况下,复杂度较低的实体将是完美的,是否可以制作这些实体的“轻量级”版本并在同一个 DomainService 中使用它们? 或者对于这种简单的数据查询场景(在数据库之上使用 EF)还有其他建议吗? (或者也许只是不关心 2011 年的带宽并始终检索完整的实体?:)
谢谢, 巴林特
(I searched a lot and didn't find an answer yet, maybe it is not possible at all:/)
Is it possible to create entities in the EDM (from which I generated my DomainService) that are not mapped at all to any DB, just used instead between the DomainService and the Client?
It might sound wierd for those who are entity framework pros:) My goal is to make it possible to return for example only a few properties of an entity instead of the whole entity.
For example I need only the name and birthdate of a user, and I don't care about the other 10-20 properties. In this case a less complex entity would be perfect, is it possible to make these "lightweight" versions of the entities and use them in the same DomainService?
Or any other suggestions for this kind of simple data querying scenario, using EF on top of the DB?
(Or maybe just don't care about the bandwith in 2011 and retrieve full entities always? :)
Thanks,
Bálint
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过选择实体的多个属性来加载匿名类型,如下所示,
http:// msdn.microsoft.com/en-us/library/bb738512.aspx
编辑..
You can load anonymous types by selecting sevaral properties of your entity like this,
http://msdn.microsoft.com/en-us/library/bb738512.aspx
Edit..