background preloader

Nhibernate

Facebook Twitter

NHibernate Best Practices with ASP.NET, 1.2nd Ed. Author's note added June 11, 2008 - Announcement of S#arp Architecture Thankfully, technologies evolve over the years. Accordingly, Microsoft has introduced ASP.NET MVC as an alternative to classic ASP.NET. I have developed a new architecture which uses many of the design principles of this article for this newer platform called S#arp Architecture. Although this article is still the recommended background reading material for S#arp Architecture, you'll find the new architecture to be simpler and more maintainable while still leveraging the best of what NHibernate has to offer. Preface to the 1.2nd Edition In March of 2006 I published my initial thoughts on NHibernate best practices with ASP.NET, generics and unit tests.

Quite simply, NHibernate is awesome. A quick thanks goes out to those who have implemented my ideas in their own work and have given plenty of ideas for improvement and consideration! Article Contents Introduction Why Use an ORM? Goals and Overview of Article. James Gregory » I think you mean a many-to-one sir. This is a question that crops up a lot, in various forms, on the Fluent NHibernate and NHibernate Users mailing lists. My one-to-one mapping isn’t working, what’s wrong? Aka Incorrectly using a one-to-one relationship when you actually need a many-to-one. There’s a common misunderstanding where people try to use a one-to-one relationship where a many-to-one is appropriate. I believe this is because people tend to get tunnel vision when designing their entities, which leads them to make incorrect assumptions.

There’s also a big distinction between what’s possible in the domain, and what’s possible by design in the database; for example, two businesses may never share an address in your application, but in the database there’s nothing stopping two rows in the Business table from referencing the same address row in the database. Many-to-one Lets have a look at what actually is a many-to-one. That is, the first and third customer both reference the first address. One-to-one. Tales from the Evil Empire. Asking questions is a skill If you’re going to get into any sort of technical job, you’re going to have to ask questions. A lot of questions. Unfortunately, too few people understand how to ask questions properly. Asking questions is a skill. It has to be learnt. Here are a few of the most common mistakes I see people make every day on Stack Overflow, or on other technical forums… 1. “I installed Orchard, and it doesn’t work. Put yourself in the shoes of someone trying to answer this.

How does it not work? Ask yourself: is there enough information for anybody who’s not you to figure out what the problem is? Notice how asking a question that is too vague will only get you more questions in return. 2. “[wall of text explaining your setup with a luxury of irrelevant details…] Why does the screen flash blue when I click the green button?” Focus on the details that are immediately useful to answering the question. 3. 4. “Where is the green button? 5. “I pressed the green button. 6. 1. 2. 3. Home - NHibernate Forge.