ドキュメントから次のOrmLite構成を考えると、指定された接続ごとにConnectionFilterを構成するための最良の方法は何ですか?
var dbFactory = new OrmLiteConnectionFactory(
"Data Source=host;Initial Catalog=RobotsMaster;Integrated Security=SSPI", //Connection String
SqlServerDialect.Provider);
dbFactory.Run(db => db.CreateTable<MasterRecord>(overwrite:false));
NoOfShards.Times(i => {
var namedShard = "robots-shard" + i;
dbFactory.RegisterConnection(namedShard,
"~/App_Data/{0}.sqlite".Fmt(shardId).MapAbsolutePath(), //Connection String
SqliteDialect.Provider);
dbFactory.OpenDbConnection(namedShard).Run(db => db.CreateTable<Robot>(overwrite:false));
});
現在、RegisterConnectionの代わりにこれを使用しています。
OrmLiteConnectionFactory.NamedConnections[namedShard] = new OrmLiteConnectionFactory("~/App_Data/{0}.sqlite".Fmt(shardId).MapAbsolutePath(), true, SqliteDialect.Provider, true) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
};
RegisterConnectionを次のようなものに変更できますか
public void RegisterConnection(string connectionKey, string connectionString, IOrmLiteDialectProvider dialectProvider, bool autoDisposeConnection = true)
{
RegisterConnection(connectionKey, new OrmLiteConnectionFactory(connectionString, autoDisposeConnection, dialectProvider, autoDisposeConnection));
}
public void RegisterConnection(string connectionKey, OrmLiteConnectionFactory ormLiteConnectionFactory)
{
NamedConnections[connectionKey] = ormLiteConnectionFactory;
}