Smart    Lucky

Smart Lucky

  • NA
  • 555
  • 640.8k

How to insert Data in individual Database using FluentNhiben

Dec 31 2014 5:59 AM


Hi friends

i have 3 database with same schema, i want to first database product table data and insert this table data in to remaining database product tables mean databases are individual but schema is same (may be database on individual machines but schema is same), and i am using following configuration for database fluentnhibenate so is it possible to do that, if it is possible can any one help me please......

Thanks

public static void InitializeSessionFactory(string connectionString = "Data Source=local;Initial Catalog=mydb;Integrated Security=true;")
{
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(connectionString).ShowSql()
)
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf<Category>())
.ExposeConfiguration(cfg => new SchemaExport(cfg)
.Create(false, false))
.BuildSessionFactory();
}

public static ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
InitializeSessionFactory();
return _sessionFactory;
}
}

public static ISession OpenSession()
{
return SessionFactory.OpenSession();
}