Exemplo n.º 1
0
 public OracleExecuteResult(DbCommand command, ReadOnlyCollection <SqlParameterInfo> parameters, IObjectReaderSession session, object value, bool useReturnValue)
     : base(command, parameters, session, value, useReturnValue)
 {
     this.command    = command;
     this.parameters = parameters;
     this.session    = session;
 }
Exemplo n.º 2
0
 public OracleExecuteResult(DbCommand command, ReadOnlyCollection <SqlParameterInfo> parameters, IObjectReaderSession session)
     : base(command, parameters, session)
 {
     this.command    = command;
     this.parameters = parameters;
     this.session    = session;
 }
Exemplo n.º 3
0
 internal MultipleResults(IProvider provider, MetaFunction function, IObjectReaderSession session, ExecuteResult executeResult)
 {
     this.provider      = provider;
     this.function      = function;
     this.session       = session;
     this.executeResult = executeResult;
     _readerProvider    = provider as IReaderProvider;
 }
Exemplo n.º 4
0
 // Methods
 public MultipleResults(SqlProvider provider, MetaFunction function, IObjectReaderSession session,
                        ExecuteResult executeResult)
 {
     this.provider      = provider;
     this.function      = function;
     this.session       = session;
     this.executeResult = executeResult;
 }
Exemplo n.º 5
0
 // Methods
 public ExecuteResult(DbCommand command, ReadOnlyCollection <SqlParameterInfo> parameters,
                      IObjectReaderSession session)
 {
     iReturnParameter = -1;
     this.command     = command;
     this.parameters  = parameters;
     this.session     = session;
 }
Exemplo n.º 6
0
		internal ExecuteResult(DbCommand command, ReadOnlyCollection<SqlParameterInfo> parameters, IObjectReaderSession session, object value, bool useReturnValue)
			: this(command, parameters, session)
		{
			this.value = value;
			this.useReturnValue = useReturnValue;
			if(this.command != null && this.parameters != null && useReturnValue)
			{
				iReturnParameter = GetParameterIndex("@RETURN_VALUE");
			}
		}
Exemplo n.º 7
0
        public IObjectReader GetNextResult(IObjectReaderSession session, bool disposeDataReader)
        {
            ObjectReaderSession <TDataReader> ors = (ObjectReaderSession <TDataReader>)session;
            IObjectReader reader = ors.GetNextResult(_materializeFunc, _namedColumns, _globals, _numberOfLocals, disposeDataReader);

            if (reader == null && disposeDataReader)
            {
                ors.Dispose();
            }
            return(reader);
        }
Exemplo n.º 8
0
            public IObjectReader GetNextResult(IObjectReaderSession session, bool disposeDataReader)
            {
                var           session2 = (ObjectReaderSession <TDataReader>)session;
                IObjectReader reader   = session2.GetNextResult(fnMaterialize, namedColumns,
                                                                globals, nLocals, disposeDataReader);

                if ((reader == null) && disposeDataReader)
                {
                    session2.Dispose();
                }
                return(reader);
            }
Exemplo n.º 9
0
            public ExecuteResult(DbCommand command, ReadOnlyCollection <SqlParameterInfo> parameters,
                                 IObjectReaderSession session, object value, bool useReturnValue)
                : this(command, parameters, session)
            {
                this.value = value;
                if (this.command != null && (this.parameters != null && parameters.Count > 0) && useReturnValue)
                {
                    iReturnParameter = GetParameterIndex("@RETURN_VALUE");

                    if (iReturnParameter == -1)
                    {
                        iReturnParameter = GetParameterIndex(":RETURN_VALUE");
                    }

                    if (iReturnParameter == -1)
                    {
                        iReturnParameter = GetParameterIndex("RETURN_VALUE");
                    }
                }
            }
Exemplo n.º 10
0
 internal override SqlProvider.ExecuteResult CreateExecuteResult(DbCommand command, ReadOnlyCollection <SqlParameterInfo> parameters, IObjectReaderSession session)
 {
     return(new OracleExecuteResult(command, parameters, session));
 }
Exemplo n.º 11
0
 internal override IExecuteResult CreateExecuteResult(DbCommand cmd, ReadOnlyCollection <SqlParameterInfo> parameters, IObjectReaderSession session,
                                                      object value, bool useReturnValue)
 {
     return(new OracleExecuteResult(cmd, parameters, session, value, useReturnValue));
 }
Exemplo n.º 12
0
        internal override IExecuteResult Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, object[] parentArgs, object[] userArgs, ICompiledSubQuery[] subQueries, object lastResult)
        {
            IExecuteResult result3;

            InitializeProviderMode();
            DbConnection connection = conManager.UseConnection(this);

            try
            {
#if FREE
                var count = GetTabesCount(connection);
                Debug.Assert(count > 0);

                if (count > Constants.LimitedTablesCount)
                {
                    throw ALinq.SqlClient.Error.TablesLimited();
                }
#endif

                DbCommand cmd = connection.CreateCommand();

                cmd.CommandText    = queryInfo.CommandText;
                cmd.Transaction    = conManager.Transaction;
                cmd.CommandTimeout = CommandTimeout;
                cmd.CommandType    = (queryInfo.Query is SqlStoredProcedureCall) ? CommandType.StoredProcedure : CommandType.Text;
                AssignParameters(cmd, queryInfo.Parameters, userArgs, lastResult);
                //if (queryInfo.Query is SqlStoredProcedureCall)

                LogCommand(Log, cmd);
                queryCount++;
                switch (queryInfo.ResultShape)
                {
                case ResultShape.Singleton:
                {
                    DbDataReader  reader  = CreateRereader(cmd.ExecuteReader());
                    IObjectReader reader2 = factory.Create(reader, true, this, parentArgs, userArgs, subQueries);
                    conManager.UseConnection(reader2.Session);
                    try
                    {
                        var objType  = typeof(OneTimeEnumerable <>).MakeGenericType(new[] { queryInfo.ResultType });
                        var bf1      = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
                        var args     = new object[] { reader2 };
                        var sequence =
                            (IEnumerable)Activator.CreateInstance(objType, bf1, null, args, null);
                        object     obj2       = null;
                        var        expression = query as MethodCallExpression;
                        MethodInfo info;
                        if ((expression != null) && ((expression.Method.DeclaringType == typeof(Queryable)) ||
                                                     (expression.Method.DeclaringType == typeof(Enumerable))))
                        {
                            string name = expression.Method.Name;
                            if (name != null)
                            {
                                if ((!(name == "First") && !(name == "FirstOrDefault")) &&
                                    !(name == "SingleOrDefault"))
                                {
                                    if (name == "Single")
                                    {
                                    }
                                }
                                else
                                {
                                    info = TypeSystem.FindSequenceMethod(expression.Method.Name, sequence);
                                    goto Label_01DE;
                                }
                            }
                            info = TypeSystem.FindSequenceMethod("Single", sequence);
                        }
                        else
                        {
                            info = TypeSystem.FindSequenceMethod("SingleOrDefault", sequence);
                        }
Label_01DE:
                        if (info != null)
                        {
                            try
                            {
                                obj2 = info.Invoke(null, new object[] { sequence });
                            }
                            catch (TargetInvocationException exception)
                            {
                                if (exception.InnerException != null)
                                {
                                    throw exception.InnerException;
                                }
                                throw;
                            }
                        }
                        return(CreateExecuteResult(cmd, queryInfo.Parameters, reader2.Session, obj2));
                    }
                    finally
                    {
                        reader2.Dispose();
                    }
                }

                case ResultShape.Sequence:
                    break;

                case ResultShape.MultipleResults:
                {
                    DbDataReader         reader5 = CreateRereader(cmd.ExecuteReader());
                    IObjectReaderSession user    = readerCompiler.CreateSession(reader5, this, parentArgs,
                                                                                userArgs, subQueries);
                    conManager.UseConnection(user);
                    MetaFunction function2     = GetFunction(query);
                    var          executeResult = CreateExecuteResult(cmd, queryInfo.Parameters, user);
                    executeResult.ReturnValue = new MultipleResults(this, function2, user, executeResult);
                    return(executeResult);
                }

                default:
                    return(CreateExecuteResult(cmd, queryInfo.Parameters, null, cmd.ExecuteNonQuery(), true));
                }

                DbDataReader  reader3 = CreateRereader(cmd.ExecuteReader());
                IObjectReader reader4 = factory.Create(reader3, true, this, parentArgs, userArgs, subQueries);
                conManager.UseConnection(reader4.Session);
                var t = typeof(OneTimeEnumerable <>).MakeGenericType(new[] {
                    TypeSystem.GetElementType(queryInfo.ResultType)
                });
                var flags  = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
                var objs   = new object[] { reader4 };
                var source = (IEnumerable)Activator.CreateInstance(t, flags, null, objs, null);
                if (typeof(IQueryable).IsAssignableFrom(queryInfo.ResultType))
                {
                    source = source.AsQueryable();
                }

                var          result   = CreateExecuteResult(cmd, queryInfo.Parameters, reader4.Session);
                MetaFunction function = GetFunction(query);
                if ((function != null) && !function.IsComposable)
                {
                    t = typeof(SingleResult <>).MakeGenericType(new[] {
                        TypeSystem.GetElementType(queryInfo.ResultType)
                    });
                    flags  = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
                    objs   = new object[] { source, result, services.Context };
                    source = (IEnumerable)Activator.CreateInstance(t, flags, null, objs, null);
                }
                result.ReturnValue = source;
                result3            = result;
            }
            finally
            {
                conManager.ReleaseConnection(this);
            }
            return(result3);
        }
Exemplo n.º 13
0
 internal ExecuteResult(DbCommand command, ReadOnlyCollection <SqlParameterInfo> parameters, IObjectReaderSession session, object value)
     : this(command, parameters, session, value, false)
 {
 }
Exemplo n.º 14
0
 internal ExecuteResult(DbCommand command, ReadOnlyCollection <SqlParameterInfo> parameters, IObjectReaderSession session)
 {
     this.command    = command;
     this.parameters = parameters;
     this.session    = session;
 }
Exemplo n.º 15
0
 internal ExecuteResult(DbCommand command, ReadOnlyCollection <SqlParameterInfo> parameters, IObjectReaderSession session, object value, bool useReturnValue)
     : this(command, parameters, session)
 {
     this.value          = value;
     this.useReturnValue = useReturnValue;
     if (this.command != null && this.parameters != null && useReturnValue)
     {
         iReturnParameter = GetParameterIndex("@RETURN_VALUE");
     }
 }
Exemplo n.º 16
0
		internal ExecuteResult(DbCommand command, ReadOnlyCollection<SqlParameterInfo> parameters, IObjectReaderSession session, object value)
			: this(command, parameters, session, value, false)
		{
		}
Exemplo n.º 17
0
		internal ExecuteResult(DbCommand command, ReadOnlyCollection<SqlParameterInfo> parameters, IObjectReaderSession session)
		{
			this.command = command;
			this.parameters = parameters;
			this.session = session;
		}