NHibernate と流暢なインターフェースに夢中になりました。後者は、リファクタリングをサポートする非常に優れたマッピングを可能にします (xml ファイルはもう必要ありません)。
しかし、誰も完璧ではないので、流暢な多対多のマッピングが欠けています。それがすでにそこにあるかどうか誰かが知っていますか?もしそうなら、単純なコード行がいいでしょう。
しかし、質問のヘッダーに固執するために、流れるような NHibernate マッピングと通常の NHibernate マッピングを組み合わせる方法はありますか。
現在、流暢なテスト セットアップには次の行を使用し、非流暢なテスト (XML マッピングを使用) には 2 番目のコード ブロックを使用します。流暢なIF AVAILABLEとXMLを使用するように流暢に伝えるにはどうすればよいですか...
var cfg = new Configuration();
cfg.AddProperties(MsSqlConfiguration.MsSql2005.ConnectionString.Is(_testConnectionstring).ToProperties());
cfg.AddMappingsFromAssembly(typeof(CatMap).Assembly);
new SchemaExport(cfg).Create(true, true);
var persistenceModel = new PersistenceModel();
persistenceModel.addMappingsFromAssembly(typeof(CatMap).Assembly);
IDictionary<string, string> properties = MsSqlConfiguration.MsSql2005.UseOuterJoin().ShowSql().ConnectionString.Is(_testConnectionstring).ToProperties();
properties.Add("command_timeout", "340");
session = new SessionSource(properties, persistenceModel).CreateSession();
流暢でなければ...
config = new Configuration();
IDictionary props = new Hashtable();
props["connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
props["dialect"] = "NHibernate.Dialect.MsSql2005Dialect";
props["connection.driver_class"] = "NHibernate.Driver.SqlClientDriver";
props["connection.connection_string"] = "Server=localhost;initial catalog=Debug;Integrated Security=SSPI";
props["show_sql"] = "true";
foreach (DictionaryEntry de in props)
{
config.SetProperty(de.Key.ToString(), de.Value.ToString());
}
config.AddAssembly(typeof(CatMap).Assembly);
SchemaExport se = new SchemaExport(config);
se.Create(true, true);
factory = config.BuildSessionFactory();
session = factory.OpenSession();
それだけです... クリス
PS: 私はこのサイトが本当に好きです。GUI は完璧で、すべての記事の質は素晴らしいです。私はそれが巨大になると思います:-) 登録する必要があります...