Subsonic Vs NHibernate

后端 未结 15 2153
醉梦人生
醉梦人生 2020-11-29 17:44

What is the concensus on when to use one of these tools adversed to the other? I find Subsonic very useful in terms of getting things done quickly, but on large projects it

相关标签:
15条回答
  • 2020-11-29 18:25

    Embrace the Impedance Mismatch!

    check this out

    :)

    Or don't. If you want performance, do it yourself. If you want it quick and easy, go with NHibernate and ActiveRecord. If you like pretending that you actually know what's going on at data access level, use NHibernate and sit with XML all day long to get a many to many going... Or just... err.. do it yourself - ADO.Net FTW!

    0 讨论(0)
  • 2020-11-29 18:26

    I think you pretty much nailed it. Subsonic generates code, so your business objects will be reflective of your database structure. nHibernate uses mapping files which map your business objects to the database so your objects can be structured however you like.

    How large of a project is this? Will there be long term support needed? Is the cost effectiveness of Subsonic going to offset any potential scaling issues?

    0 讨论(0)
  • 2020-11-29 18:28

    I get asked this question a lot and really it comes down to how much you want to fiddle. I can't tell you how damaging Chris Cyvas's comments RE SubSonic scaling have been - and I've been responding to these ever since :(.

    The deal is - perf-wise, SubSonic scales very nicely. In terms of project growth - ANY tool you use will require your attention. Even NHibernate.

    I wrote a post on how to use the Repository pattern with DI (as you would with NHIb or any tool for that matter) with SubSonic 2.1:

    http://blog.wekeroad.com/blog/subsonic-writing-decoupled-testable-code-with-subsonic-2-1/

    I also wrote a post on the performance of SubSOnic:

    http://blog.wekeroad.com/blog/subsonic-scaling/

    Hope this helps.

    0 讨论(0)
  • 2020-11-29 18:31

    Slightly off topic, but in a similar vein. Have you looked at Castle ActiveRecord it is written on top of NHibernate and removes the need to spend time creating XML mappings from code to the database. Like NHibernate you can structure your domain objects as you want and later generate a database schema from this structure.

    Using ActiveWriter, a contributed tool, you can easily map from your database to domain objects.

    0 讨论(0)
  • 2020-11-29 18:34

    We bootstrapped with subsonic and are now trying to evaluate if we are going to switch to nhibernate now that we are at the pain points of subsonic.

    Our other option is to create some middle ground where we use subsonic to query and load up arbitrary objects with their "execute as typed list" functionality that does a name based mapping off of an arbitrary linq style sql statement. Or to try and recreate some of it in nhibernate and refactor the rest.

    So I say subsonic makes sense in small apps, but maintenance on subsonic apps gets pretty hairy, we have especially hard times with overlapping validation code, and pre/post in code triggered events. For an active record pattern, subsonic is definitely 80% there, but does somethings in a flaky way, and stops you from having any real control over your inheritance hierarchy, since every class must inherit a table to get back to that table.

    0 讨论(0)
  • 2020-11-29 18:34

    The advice I've gotten on the topic is that Subsonic does not scale up to handle more complex scenarios and so if you go down that road you'll end up with a job trying to swap over to a more advanced ORM.

    I'm thus more interested in using NHibernate for complex cases, Castle Active Record for simpler cases and am keeping an eye on Fluent NHibernate which should make NHibernate mapping a lot easier (especially once the convention based mapping support is improved).

    0 讨论(0)
提交回复
热议问题