public override Task <object?> ExecuteScalarAsync(CancellationToken cancellationToken)
            {
                if (_dataContext._batchCounter > 0)
                {
                    throw new LinqException("Incompatible batch operation.");
                }

                string data;

                SetCommand(true);

                var queryContext = Query.Queries[QueryNumber];

                var q = _dataContext.GetSqlOptimizer().PrepareStatementForRemoting(queryContext.Statement, _dataContext.MappingSchema, _evaluationContext);
                var currentParameters = q.CollectParameters();

                data = LinqServiceSerializer.Serialize(
                    _dataContext.SerializationMappingSchema,
                    q,
                    currentParameters,
                    _evaluationContext.ParameterValues,
                    QueryHints);

                _client = _dataContext.GetClient();

                return(_client.ExecuteScalarAsync(_dataContext.Configuration, data));
            }
            public override Task <int> ExecuteNonQueryAsync(CancellationToken cancellationToken)
            {
                string data;

                SetCommand(true);

                var queryContext = Query.Queries[QueryNumber];

                var q = _dataContext.GetSqlOptimizer().PrepareStatementForRemoting(queryContext.Statement, _dataContext.MappingSchema, _evaluationContext);
                var currentParameters = q.CollectParameters();

                data = LinqServiceSerializer.Serialize(
                    _dataContext.SerializationMappingSchema,
                    q,
                    currentParameters,
                    _evaluationContext.ParameterValues,
                    QueryHints);

                if (_dataContext._batchCounter > 0)
                {
                    _dataContext._queryBatch !.Add(data);
                    return(TaskCache.MinusOne);
                }

                _client = _dataContext.GetClient();

                return(_client.ExecuteNonQueryAsync(_dataContext.Configuration, data));
            }
            public override IDataReader ExecuteReader()
            {
                _dataContext.ThrowOnDisposed();

                if (_dataContext._batchCounter > 0)
                {
                    throw new LinqException("Incompatible batch operation.");
                }

                string data;

                SetCommand(true);

                var queryContext = Query.Queries[QueryNumber];

                var q = _dataContext.GetSqlOptimizer().PrepareStatementForRemoting(queryContext.Statement, _dataContext.MappingSchema, _evaluationContext);

                var currentParameters = q.CollectParameters();

                data = LinqServiceSerializer.Serialize(
                    _dataContext.SerializationMappingSchema,
                    q,
                    currentParameters,
                    _evaluationContext.ParameterValues,
                    QueryHints);

                _client = _dataContext.GetClient();

                var ret = _client.ExecuteReader(_dataContext.Configuration, data);

                var result = LinqServiceSerializer.DeserializeResult(_dataContext.SerializationMappingSchema, ret);

                return(new ServiceModelDataReader(_dataContext.SerializationMappingSchema, result));
            }
            public override async Task <IDataReaderAsync> ExecuteReaderAsync(CancellationToken cancellationToken)
            {
                if (_dataContext._batchCounter > 0)
                {
                    throw new LinqException("Incompatible batch operation.");
                }

                string data;

                SetCommand(true);

                var queryContext = Query.Queries[QueryNumber];

                var q = _dataContext.GetSqlOptimizer().PrepareStatementForRemoting(queryContext.Statement, _dataContext.MappingSchema, _evaluationContext);
                var currentParameters = q.CollectParameters();

                data = LinqServiceSerializer.Serialize(
                    _dataContext.SerializationMappingSchema,
                    q,
                    currentParameters,
                    _evaluationContext.ParameterValues,
                    QueryHints);

                _client = _dataContext.GetClient();

                var ret = await _client.ExecuteReaderAsync(_dataContext.Configuration, data).ConfigureAwait(Common.Configuration.ContinueOnCapturedContext);

                var result = LinqServiceSerializer.DeserializeResult(_dataContext.SerializationMappingSchema, ret);
                var reader = new ServiceModelDataReader(_dataContext.SerializationMappingSchema, result);

                return(new DataReaderAsync(reader));
            }
Esempio n. 5
0
            public override int ExecuteNonQuery()
            {
                string data;

                SetCommand(true);

                var queryContext = Query.Queries[QueryNumber];

                var q = _dataContext.GetSqlOptimizer().PrepareStatementForRemoting(queryContext.Statement,
                                                                                   _dataContext.MappingSchema, queryContext.Aliases !, _evaluationContext);

                data = LinqServiceSerializer.Serialize(
                    _dataContext.SerializationMappingSchema,
                    q,
                    _evaluationContext.ParameterValues,
                    QueryHints);

                if (_dataContext._batchCounter > 0)
                {
                    _dataContext._queryBatch !.Add(data);
                    return(-1);
                }

                _client = _dataContext.GetClient();

                return(_client.ExecuteNonQuery(_dataContext.Configuration, data));
            }
Esempio n. 6
0
            public override object?ExecuteScalar()
            {
                if (_dataContext._batchCounter > 0)
                {
                    throw new LinqException("Incompatible batch operation.");
                }

                string data;

                SetCommand(true);

                var queryContext = Query.Queries[QueryNumber];

                var sqlOptimizer = _dataContext.GetSqlOptimizer();
                var q            = sqlOptimizer.PrepareStatementForRemoting(queryContext.Statement, _dataContext.MappingSchema, queryContext.Aliases !, _evaluationContext);

                data = LinqServiceSerializer.Serialize(
                    _dataContext.SerializationMappingSchema,
                    q,
                    _evaluationContext.ParameterValues, QueryHints);

                _client = _dataContext.GetClient();

                return(_client.ExecuteScalar(_dataContext.Configuration, data));
            }
            public override Task <int> ExecuteNonQueryAsync(CancellationToken cancellationToken)
            {
                string data;

                lock (Query)
                {
                    SetCommand(true);

                    var queryContext = Query.Queries[QueryNumber];

                    var q = _dataContext.GetSqlOptimizer().OptimizeStatement(queryContext.Statement, _dataContext.MappingSchema, _dataContext.InlineParameters, true);
                    data = LinqServiceSerializer.Serialize(
                        _dataContext.SerializationMappingSchema,
                        q,
                        q.IsParameterDependent ? q.Parameters.ToArray() : queryContext.GetParameters(),
                        QueryHints);
                }

                if (_dataContext._batchCounter > 0)
                {
                    _dataContext._queryBatch !.Add(data);
                    return(TaskCache.MinusOne);
                }

                _client = _dataContext.GetClient();

                return(_client.ExecuteNonQueryAsync(_dataContext.Configuration, data));
            }
            public override Task <object?> ExecuteScalarAsync(CancellationToken cancellationToken)
            {
                if (_dataContext._batchCounter > 0)
                {
                    throw new LinqException("Incompatible batch operation.");
                }

                string data;

                lock (Query)
                {
                    SetCommand(true);

                    var queryContext = Query.Queries[QueryNumber];

                    var q = _dataContext.GetSqlOptimizer().OptimizeStatement(queryContext.Statement, _dataContext.MappingSchema, _dataContext.InlineParameters, true);

                    data = LinqServiceSerializer.Serialize(
                        _dataContext.SerializationMappingSchema,
                        q,
                        q.IsParameterDependent ? q.Parameters.ToArray() : queryContext.GetParameters(), QueryHints);
                }

                _client = _dataContext.GetClient();

                return(_client.ExecuteScalarAsync(_dataContext.Configuration, data));
            }
            public override async Task <IDataReaderAsync> ExecuteReaderAsync(CancellationToken cancellationToken)
            {
                if (_dataContext._batchCounter > 0)
                {
                    throw new LinqException("Incompatible batch operation.");
                }

                string data;

                lock (Query)
                {
                    SetCommand(true);

                    var queryContext = Query.Queries[QueryNumber];

                    var q = _dataContext.GetSqlOptimizer().OptimizeStatement(queryContext.Statement, _dataContext.MappingSchema, _dataContext.InlineParameters, true);

                    data = LinqServiceSerializer.Serialize(
                        _dataContext.SerializationMappingSchema,
                        q,
                        q.IsParameterDependent ? q.Parameters.ToArray() : queryContext.GetParameters(),
                        QueryHints);
                }

                _client = _dataContext.GetClient();

                var ret = await _client.ExecuteReaderAsync(_dataContext.Configuration, data).ConfigureAwait(Common.Configuration.ContinueOnCapturedContext);

                var result = LinqServiceSerializer.DeserializeResult(_dataContext.SerializationMappingSchema, ret);
                var reader = new ServiceModelDataReader(_dataContext.SerializationMappingSchema, result);

                return(new DataReaderAsync(reader));
            }
            public override int ExecuteNonQuery()
            {
                string data;

                // locks are bad, m'kay?
                lock (Query)
                {
                    SetCommand(true);

                    var queryContext = Query.Queries[QueryNumber];

                    var q = _dataContext.GetSqlOptimizer().OptimizeStatement(queryContext.Statement, _dataContext.MappingSchema, _dataContext.InlineParameters, true);

                    q.CollectParameters();

                    data = LinqServiceSerializer.Serialize(
                        _dataContext.SerializationMappingSchema,
                        q,
                        queryContext.GetParameters(),
                        QueryHints);
                }

                if (_dataContext._batchCounter > 0)
                {
                    _dataContext._queryBatch !.Add(data);
                    return(-1);
                }

                _client = _dataContext.GetClient();

                return(_client.ExecuteNonQuery(_dataContext.Configuration, data));
            }
Esempio n. 11
0
            public override IDataReader ExecuteReader()
            {
                _dataContext.ThrowOnDisposed();

                if (_dataContext._batchCounter > 0)
                {
                    throw new LinqException("Incompatible batch operation.");
                }

                string data;

                lock (Query)
                {
                    SetCommand(true);

                    var queryContext = Query.Queries[QueryNumber];

                    var q = _dataContext.GetSqlOptimizer().OptimizeStatement(queryContext.Statement, _dataContext.MappingSchema, _dataContext.InlineParameters);

                    data = LinqServiceSerializer.Serialize(
                        _dataContext.SerializationMappingSchema,
                        q,
                        q.IsParameterDependent ? q.Parameters.ToArray() : queryContext.GetParameters(),
                        QueryHints);
                }

                _client = _dataContext.GetClient();

                var ret = _client.ExecuteReader(_dataContext.Configuration, data);

                var result = LinqServiceSerializer.DeserializeResult(_dataContext.SerializationMappingSchema, ret);

                return(new ServiceModelDataReader(_dataContext.SerializationMappingSchema, result));
            }