当前位置: 首页>>代码示例>>C#>>正文


C# IQuery.AutoCommit方法代码示例

本文整理汇总了C#中IQuery.AutoCommit方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.AutoCommit方法的具体用法?C# IQuery.AutoCommit怎么用?C# IQuery.AutoCommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQuery的用法示例。


在下文中一共展示了IQuery.AutoCommit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteQuery

        protected virtual IQueryResponse[] ExecuteQuery(IQuery context, SqlQuery query)
        {
            // TODO: Log a debug message..

            IQueryResponse[] response = null;

            try {
                // Execute the Query (behaviour for this comes from super).
                response = CoreExecuteQuery(context, query.Text, query.Parameters, query.ParameterStyle);

                // 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.Session.Rollback();
                    } else {
                        try {
                            // Otherwise commit.
                            context.Session.Commit();
                        } catch (Exception) {
                            foreach (IQueryResponse queryResponse in response) {
                                // Dispose this response if the commit failed.
                                DisposeResult(queryResponse.ResultId);
                            }

                            // And throw the SQL Exception
                            throw;
                        }
                    }
                }
            }
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:40,代码来源:ServerConnector.cs

示例2: CoreExecuteQuery

        protected IQueryResponse[] CoreExecuteQuery(IQuery context, string text, IEnumerable<QueryParameter> parameters, QueryParameterStyle parameterStyle)
        {
            // Where Query result eventually resides.
            int resultId = -1;

            // For each StreamableObject in the query object, translate it to a
            // IRef object that presumably has been pre-pushed onto the server from
            // the client.

            // Evaluate the sql Query.
            var query = new SqlQuery(text, parameterStyle);
            if (parameters != null) {
                foreach (var p in parameters) {
                    var c = p.SqlType.TypeCode;
                    switch (c) {
                        case SqlTypeCode.Blob:
                        case SqlTypeCode.Clob:
                        case SqlTypeCode.LongVarBinary:
                        case SqlTypeCode.LongVarChar:
                        case SqlTypeCode.VarBinary:
                            throw new NotImplementedException("TODO: Download the Large-Objects and replace with a reference");
                        default:
                            query.Parameters.Add(p);
                            break;
                    }
                }
            }

            var stopwatch = new Stopwatch();
            stopwatch.Start();

            var results = context.ExecuteQuery(query);
            var responses = new IQueryResponse[results.Length];
            int j = 0;

            foreach (var result in results) {
                QueryResult queryResult;
                try {
                    if (result.Type == StatementResultType.Exception)
                        throw result.Error;

                    queryResult = new QueryResult(query, result, context.AutoCommit());
                    resultId = AddResult(queryResult);
                } catch (Exception) {
                    if (resultId != -1)
                        DisposeResult(resultId);

                    throw;
                }

                var taken = stopwatch.ElapsedMilliseconds;

                // Return the Query response
                responses[j] = new QueryResponse(resultId, queryResult, (int)taken, "");

                j++;
            }

            stopwatch.Stop();
            return responses;
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:61,代码来源:ServerConnector.cs


注:本文中的IQuery.AutoCommit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。