コード例 #1
0
        /// <summary>
        /// Queries the data store with Mongo Bson filter and projection.
        /// </summary>
        /// <param name="parser">The parser.</param>
        /// <returns>The query results collection.</returns>
        /// <exception cref="WitsmlException"></exception>
        protected List <T> QueryEntities(WitsmlQueryParser parser)
        {
            try
            {
                if (OptionsIn.RequestObjectSelectionCapability.True.Equals(parser.RequestObjectSelectionCapability()))
                {
                    Logger.DebugFormat("Requesting {0} query template.", DbCollectionName);
                    var queryTemplate = CreateQueryTemplate();
                    return(queryTemplate.AsList());
                }

                var returnElements = parser.ReturnElements();
                Logger.DebugFormat("Querying with return elements '{0}'", returnElements);

                var fields  = GetProjectionPropertyNames(parser);
                var ignored = GetIgnoredElementNamesForQuery(parser);

                Logger.DebugFormat("Querying {0} MongoDb collection.", DbCollectionName);
                var query = new MongoDbQuery <T>(Container, GetCollection(), parser, fields, ignored);
                return(FilterRecurringElements(query));
            }
            catch (MongoException ex)
            {
                Logger.ErrorFormat("Error querying {0} MongoDb collection: {1}", DbCollectionName, ex);
                throw new WitsmlException(ErrorCodes.ErrorReadingFromDataStore, ex);
            }
        }
コード例 #2
0
 /// <summary>
 /// Filters the recurring elements within each data object returned by the specified query.
 /// </summary>
 /// <param name="query">The query.</param>
 /// <returns>The query results collection.</returns>
 protected virtual List <T> FilterRecurringElements(MongoDbQuery <T> query)
 {
     // NOTE: this method can be overridden to include additional context
     return(query.FilterRecurringElements(query.Execute()));
 }