开发者

C# Winforms, migrating to NHibernate

We are currently developing a new WinForms application (C# .NET 3.5).

The project is currently 40% complete however we're spending a considerable amount of time writing the DAL implementation (CRUD). We now want to move NHibernate as an ORM solution to take advantage of its many benefits and to relieve some of the DAL coding work.

We would much rather concentrate on solving business problems.

At the current time we plan to migrate to NHibernate and FluentHibernate but have a few questions.

  1. Is the change to NHibernate worth the steep learning curve? From a performance point of view do you think NHibernate would be a more sensible option than continuing to wri开发者_Python百科te our own?

  2. We currently employ "soft delete" and read data through views in the database which have a field "Deleted = null" (Deleted is a TIMESTAMP). From my understanding, when we map each class we can also specify a "Where" clause which means we no longer need any "filtering" views in our database? Is that correct?

  3. In relation to the question above. We also have a "Purge" function that can delete records from the database. Can we employ "soft delete" and still have a purge function?

  4. Can we persist BLOBS to the database through NHibernate?

  5. What would be the best migration strategy for us? How would you get started on a NHibernate migration, keeping in mind that the application has not been released and we are open to having the database structure changed. Ideally I am thinking to map each of our business objects and then have NHibernate generate the schema for us, does this sound like a good way to go?

  6. Can NHibernate work with Lookup data? We currently read lookup data into a global dictionary that we use through the life of the application. Can we still do this with NHibernate.

Apologies if some of these questions are elementary, I am still trying to get a handle on NHibernate.


(Answers to your question below, referencing the original question number)

  1. Going to NHibernate is absolutely worth the learning curve - did it at my current job, and we've never looked back. NHibernate in action is an excellent book to start with.

  2. You can easily include a 'Where' clause as part of your map. We use it for filtering some common-use tables and views in our NHibernate mappings.

  3. For your purge function, just add a secondary map that reverses the where clause (or one without the flag filtered) and you're golden (we sometimes have several maps to the same entities for data shaping).

  4. RE Blobs, etc. here's an article on them by Ayende, and one on Calyptus.

  5. Migration is probably a larger question - personally, we use a repository pattern with an interface for the repository (for unit testing and mocks), a concrete implementation of the repository, and our model (POCOs). We keep no NHibernate specific code anywhere outside of our repositories to reduce dependencies, etc. and to aid in testing.
    Again, look at NHibernate in action for some great info on the product, as well as NHForge.org, TekPub for their NHibernate series, etc. (I even have some tutorials on my blog, linked in my profile).

  6. For lookup data, NHibernate works fine, and also supports cacheing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜