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...
Add a new folder named
EntityModeMapto theSessionRecipesproject.Add a new class named
Recipeto 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"); } protected override void AddInitialData(ISession session) { var movieActors = new List<Dictionary<string, object>>() { new Dictionary<string, object>() { {"Actor...