HORK allows the developer to control the behaviour of entities and database operations by using a set of Behaviour Properties.
Behavior Properties are enum values which can be added or removed from the DBContext singleton. When HORK has to save or load data, the behavious configured in DBContext will dictate how the data is saved or loaded.
HORK includes the following user-configurable behaviours:
Enables lazy loading. When an entity is loaded from the database, all child entities are also loaded at the same time.
Insert data in all entites in the object graph. Use HORKRepository or HORKTransaction to get cascaded inserts.
Update data in all entites in the object graph. Use HORKRepository or HORKTransaction to get cascaded updates.
Delete data in all entites in the object graph. Use HORKRepository or HORKTransaction to get cascaded deletes.
Logs all SQL queries to the HORK logfile at C:\ProgramData\HORK\horkout.log. Without this behaviour, only errors are logged.
Validate NULL-ability and value lengths when saving data. If enabled, this will cause an exception to be thrown if a value being saved into the database is NULL (and cannot be null in the database) or is too long for the database.
Execute all database operations in a single transaction. Use HORKRepository with this property to have data inserted via a transaction. If HORKTransaction is used, and this property is not set, the entity data will still be saved in a transaction.
When you start using HORK there are no behavior properties set. To use a behaviour property you need to add it to the DBContext, like this:
DBContext.AddBehavior(EntityBehavior.Properties.ENTITY_LOG_SQL);All operations which occur after this property is set will log SQL to the HORK log file.
When the property is no longer needed, it can just be removed from DBContext, like this: