예제 #1
0
 protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
 {
     if (behavior != CommandBehavior.Default)
         throw new NotSupportedException();
     Notation notation = new Notation();
     YYParser parser = new YYParser(notation);
     object result = parser.yyparseSafe(new Tokenizer(_commandText));
     QueryContext context = new QueryContext(DatabaseDictionary);
     context.DatabaseDictionary.SearchPath = _searchPath;
     Optimizer optimizer = new Optimizer(context);
     optimizer.Process(notation);
     QueryBinder binder = new QueryBinder();
     binder.IsServerQuery = optimizer.IsServerQuery;
     binder.Process(notation);
     optimizer.PostProcess(notation);
     if (BeforeExecute != null)
         BeforeExecute(this, notation, optimizer, context);
     Notation.Record[] recs = notation.Select(Descriptor.Root, 1);
     Object[] raw_parameters = null;
     if (recs.Length > 0)
     {
         Notation.Record[] recsd = notation.Select(recs[0].Arg0, Descriptor.Binding, 1);
         if (recsd.Length > 0)
         {
             Symbol[] bindings = Lisp.ToArray<Symbol>(recsd[0].args[0]);
             raw_parameters = new object[bindings.Length];
             for (int k = 0; k < bindings.Length; k++)
             {
                 recsd = notation.Select(bindings[k], Descriptor.Link, 1);
                 if (recsd.Length > 0)
                 {
                     DataEngine.Parameter p = (DataEngine.Parameter)recsd[0].Arg0;
                     raw_parameters[k] = _parameters[p.ParameterName].Value;
                 }
             }
         }
     }
     Translator translator = new Translator(context);
     QueryNode rootNode = translator.Process(notation);
     Resultset rs = rootNode.Get(context, raw_parameters);
     optimizer.ProcessResults(rs);
     return new DataReader(rs, context);
 }