* Fixes of errors detected while integrating DynamORM to existing project
* New features (VirtualColumn, VirtualMode, BeginBlock, EndBlock)
This commit is contained in:
@@ -196,7 +196,7 @@ namespace DynamORM
|
||||
Dictionary<string, DynamicSchemaColumn> schema = null;
|
||||
|
||||
lock (SyncLock)
|
||||
schema = Schema.TryGetValue(table.GetType().FullName) ??
|
||||
schema = Schema.TryGetValue(table.ToLower()) ??
|
||||
BuildAndCacheSchema(table, null);
|
||||
|
||||
return schema;
|
||||
@@ -417,6 +417,7 @@ namespace DynamORM
|
||||
{
|
||||
IDbConnection conn = null;
|
||||
DynamicConnection ret = null;
|
||||
bool opened = false;
|
||||
|
||||
lock (SyncLock)
|
||||
{
|
||||
@@ -427,6 +428,7 @@ namespace DynamORM
|
||||
conn = _provider.CreateConnection();
|
||||
conn.ConnectionString = _connectionString;
|
||||
conn.Open();
|
||||
opened = true;
|
||||
|
||||
TransactionPool.Add(conn, new Stack<IDbTransaction>());
|
||||
CommandsPool.Add(conn, new List<IDbCommand>());
|
||||
@@ -436,7 +438,10 @@ namespace DynamORM
|
||||
conn = TransactionPool.Keys.First();
|
||||
|
||||
if (conn.State != ConnectionState.Open)
|
||||
{
|
||||
conn.Open();
|
||||
opened = true;
|
||||
}
|
||||
}
|
||||
|
||||
ret = new DynamicConnection(this, conn, _singleTransaction);
|
||||
@@ -445,6 +450,9 @@ namespace DynamORM
|
||||
ret = _tempConn;
|
||||
}
|
||||
|
||||
if (opened)
|
||||
ExecuteInitCommands(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -491,6 +499,19 @@ namespace DynamORM
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets contains commands executed when connection is opened.</summary>
|
||||
public List<string> InitCommands { get; set; }
|
||||
|
||||
private void ExecuteInitCommands(IDbConnection conn)
|
||||
{
|
||||
if (InitCommands != null)
|
||||
using (IDbCommand command = conn.CreateCommand())
|
||||
foreach (string commandText in InitCommands)
|
||||
command
|
||||
.SetCommand(commandText)
|
||||
.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
#endregion Connection
|
||||
|
||||
#region Transaction
|
||||
|
||||
Reference in New Issue
Block a user