亚音速 poco 类的扩展方法?

发布于 2024-10-16 21:35:05 字数 378 浏览 2 评论 0原文

我正在考虑从流畅的 nhibernate 切换到 subsonic,因为 nhib 似乎有大量的内存占用,我真的不喜欢,但我只是想检查 subsonic (可能是简单的存储库)如何处理:

  • 添加额外的字段到数据库:目前我可以将字典值映射到数据库中的字段,这非常酷,这在亚音速中可能吗? (或类似的东西?)

    FWIW:DynamicComponent(x => x.PropertyBag, GetDynamicComponentPart);其中 propertybag 是字典。

  • 多对多关系

  • 级联保存/删除
  • 将复杂对象映射到 xml 或 varchar(max) 列(显然将其序列化为 xml)

I'm considering switching from fluent nhibernate to subsonic as nhib just seems to have a MASSIVE memory footprint which I'm really not enjoying, but I just want to check how subsonic (the simple repository probably) would cope with:

  • adding extra fields to a database: at the moment I can map a dictionary value to a field in the database which is VERY cool, is this possible in subsonic? (or anything similar?)

    FWIW: DynamicComponent(x => x.PropertyBag, GetDynamicComponentPart); where propertybag is a Dictionary.

  • many to many relationships

  • cascading saves/deletes
  • mapping a complex object to an xml or varchar(max) column (seralize it to xml obviously)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梨涡少年 2024-10-23 21:35:05
* 添加额外的字段到数据库:目前我可以映射一个

字典中某个字段的值
非常酷的数据库,是这个吗
亚音速可能吗? (或任何东西
类似?)

 FWIW:DynamicComponent(x => x.PropertyBag,

获取动态组件部分);在哪里
propertybag 是一个字典。

添加字段相当简单。只需将字段添加到表中,然后从 T4 模板重新生成类。

不过,您不会获得任何超出基本原始类型的映射。当然不是某个领域的字典。

* 多对多关系

您必须对 T4 模板进行自定义修改才能获得对多对多表的任何类型的支持。 SubSonic 就像对待任何其他桌子一样对待它们。

我已经做了这样的修改,但它们的用处有限。

* 级联保存/删除

仅在 RDBMS 端。也就是说,如果您使用级联设置外键关系。 SubSonic 不做这些。

* 将复杂对象映射到 xml 或 varchar(max) 列(序列化

显然是xml)

不。你得不到这样的支持。没有可扩展性挂钩来插入您自己的类型转换器。

SubSonic 是与 NHibernate 完全不同的领域。我会把 NHib 称为 ORM,但我不会这样称呼 SubSonic。 SubSonic 的作者 Rob Conery 将其称为查询工具。

它非常简单,这是它的目标和优点(也是缺点)。它有助于以强类型的方式进行查询和修改。与 NHib 甚至实体框架相比,它缺乏大量的功能和可配置性/可扩展性。

我会警告不要从 NHib 迁移到 SS,特别是如果您已经在 NHibernate 中实现了一定数量的功能。并不是说SS是一个不好的工具,而是它有很多限制。

* adding extra fields to a database: at the moment I can map a

dictionary value to a field in the
database which is VERY cool, is this
possible in subsonic? (or anything
similar?)

  FWIW: DynamicComponent(x => x.PropertyBag,

GetDynamicComponentPart); where
propertybag is a Dictionary.

Adding fields is fairly simple. Just add the field to the table, then re-generate the classes from the T4 template.

You won't get any mapping beyond basic primitive types, though. Certainly not a dictionary in a field.

* many to many relationships

You will have to make custom modifications to the T4 template to get any sort of support for many-to-many tables. SubSonic just treats them like any other table.

I have made such modifications and they are of limited usefulness.

* cascading saves/deletes

Only on the RDBMS side. That is, if you setup foreign key relationships with cascades. SubSonic doesn't do any of this.

* mapping a complex object to an xml or varchar(max) column (seralize

it to xml obviously)

Nope. You get no support like this. There are no extensibility hooks to insert your own type converters.

SubSonic is a completely different field from NHibernate. I would call NHib an ORM, but I would not call SubSonic that. Rob Conery, the author of SubSonic, would call it a query tool.

It is very simplistic, which is its goal and strength (as well as weakness). It assists with querying and modifications in a strongly typed way. It lacks a huge amount of features and configurability/extensibility compared to NHib or even Entity Framework.

I would caution against moving from NHib to SS, especially if you have any amount of functionality implemented in NHibernate already. Not that SS is a bad tool, but it has a lot of restrictions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文