Permalink
Browse files

Added support for CommandTimeout and OneTimeCommandTimeout

  • Loading branch information...
1 parent 26163d7 commit 62c95a4bb385d6c053166e3d747211672efc08bf Brad Robinson committed Jun 1, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 PetaPoco/PetaPoco.cs
View
@@ -1481,9 +1481,26 @@ public void Save(object poco)
Save(pd.TableInfo.TableName, pd.TableInfo.PrimaryKey, poco);
}
+ public int CommandTimeout { get; set; }
+ public int OneTimeCommandTimeout { get; set; }
+
void DoPreExecute(IDbCommand cmd)
{
+ // Setup command timeout
+ if (OneTimeCommandTimeout != 0)
+ {
+ cmd.CommandTimeout = OneTimeCommandTimeout;
+ OneTimeCommandTimeout = 0;
+ }
+ else if (CommandTimeout!=0)
+ {
+ cmd.CommandTimeout = CommandTimeout;
+ }
+
+ // Call hook
OnExecutingCommand(cmd);
+
+ // Save it
_lastSql = cmd.CommandText;
_lastArgs = (from IDataParameter parameter in cmd.Parameters select parameter.Value).ToArray();
}

0 comments on commit 62c95a4

Please sign in to comment.