本文整理汇总了C#中IQuery.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.Commit方法的具体用法?C# IQuery.Commit怎么用?C# IQuery.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQuery
的用法示例。
在下文中一共展示了IQuery.Commit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTestData
private void AddTestData(IQuery context)
{
var table = context.GetMutableTable(ObjectName.Parse("APP.people"));
var row = table.NewRow();
// row.SetValue("id", DataObject.Integer(0));
row.SetDefault(0, context);
row.SetValue("first_name", DataObject.String("John"));
row.SetValue("last_name", DataObject.String("Doe"));
row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1977, 01, 01)));
row.SetValue("active", DataObject.Boolean(false));
table.AddRow(row);
row = table.NewRow();
// row.SetValue("id", DataObject.Integer(1));
row.SetDefault(0, context);
row.SetValue("first_name", DataObject.String("Jane"));
row.SetValue("last_name", DataObject.String("Doe"));
row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1978, 11, 01)));
row.SetValue("active", DataObject.Boolean(true));
table.AddRow(row);
row = table.NewRow();
// row.SetValue("id", DataObject.Integer(2));
row.SetDefault(0, context);
row.SetValue("first_name", DataObject.String("Roger"));
row.SetValue("last_name", DataObject.String("Rabbit"));
row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1985, 05, 05)));
row.SetValue("active", DataObject.Boolean(true));
table.AddRow(row);
context.Commit();
}
示例2: ExecuteQuery
protected virtual IQueryResponse[] ExecuteQuery(IQuery context, string text, IEnumerable<QueryParameter> parameters)
{
// TODO: Log a debug message..
IQueryResponse[] response = null;
try {
// Execute the Query (behaviour for this comes from super).
response = CoreExecuteQuery(context, text, parameters);
// Return the result.
return response;
} finally {
// This always happens after tables are unlocked.
// Also guarenteed to happen even if something fails.
// If we are in auto-commit mode then commit the Query here.
// Do we auto-commit?
if (context.AutoCommit()) {
// If an error occured then roll-back
if (response == null) {
// Rollback.
context.Rollback();
} else {
try {
// Otherwise commit.
context.Commit();
} catch (Exception) {
foreach (IQueryResponse queryResponse in response) {
// Dispose this response if the commit failed.
DisposeResult(queryResponse.ResultId);
}
// And throw the SQL Exception
throw;
}
}
}
}
}