Beispiel #1
0
        public IResultSet Search(IQuery query)
        {
            EnsureConnected();
            var       yazQuery = Yaz.ZOOM_query_create();
            ResultSet resultSet;

            try
            {
                // branching out to right YAZ-C call
                if (query is ICQLQuery)
                {
                    Yaz.ZOOM_query_cql(yazQuery, query.QueryString);
                }
                else if (query is IPrefixQuery)
                {
                    Yaz.ZOOM_query_prefix(yazQuery, query.QueryString);
                }
                else
                {
                    throw new NotImplementedException();
                }

                var yazResultSet = Yaz.ZOOM_connection_search(ZConnection, yazQuery);
                // error checking C-style
                var errorCode = Yaz.ZOOM_connection_errcode(ZConnection);

                if (errorCode != Yaz.ZoomErrorNone)
                {
                    Yaz.ZOOM_resultset_destroy(yazResultSet);
                }

                CheckErrorCodeAndThrow(errorCode);

                // everything ok, create result set
                resultSet = new ResultSet(yazResultSet, this);
            }
            finally
            {
                // deallocate yazQuery also when exceptions
                Yaz.ZOOM_query_destroy(yazQuery);
            }
            return(resultSet);
        }