O'Reilly logo

NHibernate 4.x Cookbook - Second Edition by Jason Dentler, Alexander Zaytsev, Gunnar Liljas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using dictionaries as entities

A little-known feature of NHibernate is EntityMode.Map. In this recipe, I'll show you how we can use this feature to persist entities without classes.

Getting ready

Follow the Getting ready step in the Save entities to the database recipe in this chapter.

How to do it...

  1. Add a new folder named EntityModeMap to the SessionRecipes project.
  2. Add a new class named Recipe to the folder:
    using System; using System.Collections; using System.Collections.Generic; using System.Linq; using NH4CookbookHelpers; using NHibernate; using NHibernate.Cfg; namespace SessionRecipes.EntityModeMap { public class Recipe : HbmMappingRecipe { protected override void Configure(Configuration cfg) { cfg.SetProperty("default_entity_mode", "dynamic-map"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required