I am working on an application using SQL Server and NHibernate. We have a concept of default data (complex objects) that needs to be created for each new object. This data can be changed for each user. However, we are struggling to create this data.
For example, let's say my application has an object Storethat has several default values Productthat I want to create when creating a new one Store. Everything about Productcan be changed by everyone’s managers Store.
As I see, there are two main options:
- Save the default data in code and write it to the database after creating a new object.
- Store the default data in the database and move it using the stored procedure / raw SQL when creating the object.
Instinctively, I'm leaning towards option two, because databases are great for moving and manipulating datasets, and option one will require a ton of dirty code that can get out of hand.
However, writing a stored procedure or source SQL has its own problems:
- We would have to overwrite the stored procedure or SQL depending on the database we are using.
- We will undermine ORM in some way (not sure if this is actually wrong). That is, we will move data without using NHibernate
, , . , - . nhibernate ( " " - SO ), , , , ( , ).
, ( SProcs ORM).
!
: "" . , , , / .