是否有相当于 NHibernate 的的组件?在实体框架中?
我们正在研究可以在我们的项目中使用哪种 ORM 技术,更具体地说是 NHibernate 与 Entity Framework 4。NHibernate
中的一个好处是可以将多个列映射到自定义类型,这要归功于“组件”映射选项。也就是说,我可以将一组列映射为给定指定类型的属性,如下所示:
Component<MyCustomType>(e => e.CreatedBy,
p =>
{
p.Map(customTypeItem => customTypeItem .prop1, "column1");
p.Map(customTypeItem => customTypeItem .prop2, "column2");
});
我在 Entity Framework 4 中没有找到类似的功能。它存在吗?或者有类似的功能吗?
We are studying which ORM technology we could use in our project, more specially NHibernate vs. Entity Framework 4.
One nice thing in NHibernate is the possibility to map several columns to a custom type, thanks to the "component" mapping option. That is, I can map a group of columns as being a property of a given specified type, like this :
Component<MyCustomType>(e => e.CreatedBy,
p =>
{
p.Map(customTypeItem => customTypeItem .prop1, "column1");
p.Map(customTypeItem => customTypeItem .prop2, "column2");
});
I haven't found a similar feature in Entity Framework 4. Does it exist ? or is there a similar functionality ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对 NHibernate 不太了解,但是可以尝试一下 EF4 的 复杂类型对象.
您可以在 EDMX 上的实际实体上定义它们(添加 -> 复杂类型),而不是标量属性。
以前没有尝试过 - 但也许它适合您的场景。
Don't know much about NHibernate, but you can try EF4's Complex Type Objects.
You define them on the actual entities on your EDMX (Add -> Complex Type), as opposed to scalar properties.
Haven't tried it before - but maybe it suits your scenario.