/// <summary> /// This will create a factory for generating persistence sessions to the defined data store /// using the entity maps defined in the assemblies as the representation of the entity to /// persistent object translation. /// </summary> /// <param name="connectionString">The connection information to the data store for the peristent entities</param> /// <param name="assemblies">Assemblies that contain the persistent entities for a given data store</param> /// <returns></returns> public ISessionFactory BuildSessionFactory(string connectionString, params Assembly[] assemblies) { BuildEnvironment(); var metadatastore = new MetadataStore(); foreach (var assembly in assemblies) { var maps = (from match in assembly.GetExportedTypes() where typeof(IEntityMap).IsAssignableFrom(match) && match.IsClass == true && match.IsAbstract == false select Activator.CreateInstance(match) as IEntityMap) .Distinct().ToList(); if (maps.Any()) { foreach (var entityMap in maps) { TableInfo tableinfo = null; if (TryCreateTableInfo(entityMap, metadatastore, out tableinfo)) { metadatastore.AddEntity(tableinfo.Entity); metadatastore.SetTableInfo(tableinfo); } } } } var factory = new SessionFactory(_environmentSettings, metadatastore, connectionString); return(factory); }