Ejemplo n.º 1
0
        private void MultiTableSelectTest(TableSelectStatement statement, object[][] expectedValues)
        {
            RowResult result   = statement.Execute();
            int       rowCount = result.FetchAll().Count;

            Assert.Equal(expectedValues.Length, rowCount);
            Assert.Equal(expectedValues.Length, result.Rows.Count);
            for (int i = 0; i < expectedValues.Length; i++)
            {
                for (int j = 0; j < expectedValues[i].Length; j++)
                {
                    Assert.Equal(expectedValues[i][j], result.Rows.ToArray()[i][j]);
                }
            }
        }
Ejemplo n.º 2
0
 protected RowResult ExecuteSelectStatement(TableSelectStatement stmt)
 {
     return(stmt.Execute());
 }
Ejemplo n.º 3
0
 public QueryStatement(TableSelectStatement statement)
 {
     this.selectStatement = statement;
     SetValues(statement.Target, statement.FilterData, statement.findParams, true);
 }
Ejemplo n.º 4
0
        public int PrepareStatement <TResult>(BaseStatement <TResult> statement)
            where TResult : BaseResult
        {
            int stmtId = Interlocked.Increment(ref _stmtId);

            switch (statement.GetType().Name)
            {
            case nameof(FindStatement):
                FindStatement fs = statement as FindStatement;
                Debug.Assert(fs != null);
                protocol.SendPrepareStatement(
                    (uint)stmtId,
                    DataAccess.PreparedStatementType.Find,
                    fs.Target.Schema.Name,
                    fs.Target.Name,
                    false,
                    fs.FilterData,
                    fs.findParams);
                break;

            case nameof(TableSelectStatement):
                TableSelectStatement ss = statement as TableSelectStatement;
                Debug.Assert(ss != null);
                protocol.SendPrepareStatement(
                    (uint)stmtId,
                    DataAccess.PreparedStatementType.Find,
                    ss.Target.Schema.Name,
                    ss.Target.Name,
                    true,
                    ss.FilterData,
                    ss.findParams);
                break;

            case nameof(ModifyStatement):
                ModifyStatement ms = statement as ModifyStatement;
                Debug.Assert(ms != null);
                protocol.SendPrepareStatement(
                    (uint)stmtId,
                    DataAccess.PreparedStatementType.Update,
                    ms.Target.Schema.Name,
                    ms.Target.Name,
                    false,
                    ms.FilterData,
                    null,
                    ms.Updates);
                break;

            case nameof(TableUpdateStatement):
                TableUpdateStatement us = statement as TableUpdateStatement;
                Debug.Assert(us != null);
                protocol.SendPrepareStatement(
                    (uint)stmtId,
                    DataAccess.PreparedStatementType.Update,
                    us.Target.Schema.Name,
                    us.Target.Name,
                    true,
                    us.FilterData,
                    null,
                    us.updates);
                break;

            case nameof(RemoveStatement):
                RemoveStatement rs = statement as RemoveStatement;
                Debug.Assert(rs != null);
                protocol.SendPrepareStatement(
                    (uint)stmtId,
                    DataAccess.PreparedStatementType.Delete,
                    rs.Target.Schema.Name,
                    rs.Target.Name,
                    false,
                    rs.FilterData,
                    null);
                break;

            case nameof(TableDeleteStatement):
                TableDeleteStatement ds = statement as TableDeleteStatement;
                Debug.Assert(ds != null);
                protocol.SendPrepareStatement(
                    (uint)stmtId,
                    DataAccess.PreparedStatementType.Delete,
                    ds.Target.Schema.Name,
                    ds.Target.Name,
                    true,
                    ds.FilterData,
                    null);
                break;

            case nameof(TableInsertStatement):
                TableInsertStatement insert = statement as TableInsertStatement;
                Debug.Assert(insert != null);
                protocol.SendPrepareStatement(
                    (uint)stmtId,
                    DataAccess.PreparedStatementType.Insert,
                    insert.Target.Schema.Name,
                    insert.Target.Name,
                    true,
                    null,
                    null,
                    null,
                    insert.values.ToArray(),
                    insert.fields,
                    false);
                break;

            case nameof(SqlStatement):
                SqlStatement sqlStatement = statement as SqlStatement;
                Debug.Assert(sqlStatement != null);
                protocol.SendPrepareStatement(
                    (uint)stmtId,
                    DataAccess.PreparedStatementType.SqlStatement,
                    null,
                    null,
                    true,
                    null,
                    null,
                    null,
                    sqlStatement.parameters.ToArray(),
                    null,
                    false,
                    sqlStatement.SQL);
                break;

            default:
                throw new NotSupportedException(statement.GetType().Name);
            }
            _preparedStatements.Add(stmtId);
            return(stmtId);
        }
Ejemplo n.º 5
0
 public RowResult FindRows(TableSelectStatement ss)
 {
     protocol.SendFind(ss.Target.Schema.Name, ss.Target.Name, true, ss.FilterData, ss.findParams);
     return(new RowResult(this));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Defines the table Select statement used to generate the view.
 /// </summary>
 /// <param name="selectFunction">The table select statement.</param>
 /// <returns>A <see cref="ViewCreateStatement"/> chaining object set with the given select statement.</returns>
 public ViewCreateStatement DefinedAs(TableSelectStatement selectFunction)
 {
     this.queryStatement = new QueryStatement(selectFunction.Clone());
     return(this);
 }