Esempio n. 1
0
 public virtual NeoDatis.Odb.Objects <T> Execute <T>(bool inMemory, int startIndex,
                                                     int endIndex, bool returnObjects, NeoDatis.Odb.Core.Query.Execution.IMatchingObjectAction
                                                     queryResultAction)
 {
     if (storageEngine.IsClosed())
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbIsClosed
                                                    .AddParameter(storageEngine.GetBaseIdentification().GetIdentification()));
     }
     if (session.IsRollbacked())
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.OdbHasBeenRollbacked
                                                    );
     }
     // When used as MultiClass Executor, classInfo is already set
     if (classInfo == null)
     {
         // Class to execute query on
         string fullClassName = NeoDatis.Odb.Core.Query.QueryManager.GetFullClassName(query
                                                                                      );
         // If the query class does not exist in meta model, return an empty
         // collection
         if (!session.GetMetaModel().ExistClass(fullClassName))
         {
             queryResultAction.Start();
             queryResultAction.End();
             query.SetExecutionPlan(new NeoDatis.Odb.Core.Query.Execution.EmptyExecutionPlan()
                                    );
             return(queryResultAction.GetObjects <T>());
         }
         classInfo = session.GetMetaModel().GetClassInfo(fullClassName, true);
     }
     // Get the query execution plan
     NeoDatis.Odb.Core.Query.Execution.IQueryExecutionPlan plan = GetExecutionPlan();
     plan.Start();
     try
     {
         if (plan.UseIndex() && NeoDatis.Odb.OdbConfiguration.UseIndex())
         {
             return(ExecuteUsingIndex <T>(plan.GetIndex(), inMemory, startIndex, endIndex, returnObjects
                                          , queryResultAction));
         }
         // When query must be applied to a single object
         if (query.IsForSingleOid())
         {
             return(ExecuteForOneOid <T>(inMemory, returnObjects, queryResultAction));
         }
         return(ExecuteFullScan <T>(inMemory, startIndex, endIndex, returnObjects, queryResultAction
                                    ));
     }
     finally
     {
         plan.End();
     }
 }