Subsonic Vs NHibernate

后端 未结 15 2154
醉梦人生
醉梦人生 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:16

    I'd recommend SubSonic if your project works with the ActiveRecord view that the database is your model. You'll get one class per table and everything just magically works. You can of course tweak and override things, but if you (or your project) fundamentally disagree with the class-per-table approach, I'd look at NHibernate since it starts with the more complex (but more flexible) approach of mapping your domain model to your database.

    If you're using a relatively simple database that's under your control (as in, you can change columns without sending eight forms to a database division oversight review board), I'd recommend starting with SubSonic and moving to NHibernate if SubSonic doesn't meet your needs.

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

    You may consider looking at Fluent NHibernate; it makes managing NHibernate a breeze. Not sure how difficult it would be to transition an existing schema, but if you're building a new application it's nice to define the domain model and generate the database in pretty much any DB server you can think of. From reading the other comments here, I think Fluent NHibernate brings NHibernate on par with SubSonic for ease of configuration.

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

    I can't give a good comparison as I've not yet actually used NHibernate on a project, but I have used SubSonic and have been very happy with it. So far, I have not hit any major obstacles when using it.

    Check out this post from Rob Conery, one of the creators of SubSonic. He talks about how to decouple your SubSonic code from the rest of the app. He even mentions the fact that this architecture would enable you to later swap out SubSonic for some other data access layer such as NHibernate or LINQ to SQL.

    I know I didn't actually answer your question, but I hope this still helps.

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

    Consider your team and project size when considering ActiveRecord.

    In my experience, ActiveRecord is an abstraction on top of NHibernate that starts leaking like a sieve when trying more complicated scenarios.

    If you have a moderately to heavily complicated or non-straightforward schema, stick with NHibernate. You can slice and dice it to near perfection.

    The other place you might get into trouble is when you need a moderately complicated query. ActiveRecord hides a lot of NHibernate's implementation... but you'll need it for a complicated query, which will become very difficult if you're completely unfamiliar with HQL. Be careful team members don't just hack away at the edges instead of learning NHibernate and HQL.

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

    I wrote a blog post recently about .NET ORMs which has Subsonic in it, and ActiveRecord. From my experience it depends on what the project is doing, Subsonic works a lot better if you come from a SQL background but NHibernate has more ontop of it. ActiveRecord is good for smaller projects, I'm not convinced it's faster for larger projects than sticking to NHibernate.

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

    Again slightly off-topic, but I'll second Castle ActiveRecord - rather than using the database as your model (Subsonic approach) or spending hours in XML spaghetti (NHibernate approach) you simply place attributes on your model classes.

    You can even get ActiveRecord to generate the database schema for you.

    We've used this approach on quite a few projects now and the benefits are as follows:

    • Easy upgrade path to NHibernate if required in the future
    • Support for simple inheritance models - eg. Car -> Vehicle
    • The schema it generates is most likely how you would have created it anyway, so you can spend more time building the app rather than worrying about keeping your model/db in sync.
    0 讨论(0)
提交回复
热议问题