[mapguide-commits] r7465 - in sandbox/jng/querydef: Common/MapGuideCommon/Services Common/MdfModel Common/MdfParser Common/PlatformBase/Services Common/Schema Server/src/PostBuild Server/src/Services/Feature Server/src/UnitTesting UnitTest/TestData/FeatureService/SQLite

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Apr 30 08:21:48 PDT 2013


Author: jng
Date: 2013-04-30 08:21:47 -0700 (Tue, 30 Apr 2013)
New Revision: 7465

Added:
   sandbox/jng/querydef/Common/MdfModel/AggregateQueryDefinition.cpp
   sandbox/jng/querydef/Common/MdfModel/AggregateQueryDefinition.h
   sandbox/jng/querydef/Common/MdfModel/BaseSelectQueryDefinition.cpp
   sandbox/jng/querydef/Common/MdfModel/BaseSelectQueryDefinition.h
   sandbox/jng/querydef/Common/MdfModel/FeatureQueryDefinition.cpp
   sandbox/jng/querydef/Common/MdfModel/FeatureQueryDefinition.h
   sandbox/jng/querydef/Common/MdfModel/GeometryInfo.cpp
   sandbox/jng/querydef/Common/MdfModel/GeometryInfo.h
   sandbox/jng/querydef/Common/MdfModel/QueryDefinition.cpp
   sandbox/jng/querydef/Common/MdfModel/QueryDefinition.h
   sandbox/jng/querydef/Common/MdfModel/QueryParameter.cpp
   sandbox/jng/querydef/Common/MdfModel/QueryParameter.h
   sandbox/jng/querydef/Common/MdfModel/SQLQueryDefinition.cpp
   sandbox/jng/querydef/Common/MdfModel/SQLQueryDefinition.h
   sandbox/jng/querydef/Common/MdfParser/IOAggregateQueryDefinition.cpp
   sandbox/jng/querydef/Common/MdfParser/IOAggregateQueryDefinition.h
   sandbox/jng/querydef/Common/MdfParser/IOFeatureQueryDefinition.cpp
   sandbox/jng/querydef/Common/MdfParser/IOFeatureQueryDefinition.h
   sandbox/jng/querydef/Common/MdfParser/IOGeometryInfo.cpp
   sandbox/jng/querydef/Common/MdfParser/IOGeometryInfo.h
   sandbox/jng/querydef/Common/MdfParser/IOQueryParameter.cpp
   sandbox/jng/querydef/Common/MdfParser/IOQueryParameter.h
   sandbox/jng/querydef/Common/MdfParser/IOQueryParameterCollection.cpp
   sandbox/jng/querydef/Common/MdfParser/IOQueryParameterCollection.h
   sandbox/jng/querydef/Common/MdfParser/IOSQLQueryDefinition.cpp
   sandbox/jng/querydef/Common/MdfParser/IOSQLQueryDefinition.h
   sandbox/jng/querydef/Common/MdfParser/IOSpatialContext.cpp
   sandbox/jng/querydef/Common/MdfParser/IOSpatialContext.h
   sandbox/jng/querydef/Common/MdfParser/IOSpatialContextCoordinate.cpp
   sandbox/jng/querydef/Common/MdfParser/IOSpatialContextCoordinate.h
   sandbox/jng/querydef/Common/MdfParser/IOSpatialContextExtent.cpp
   sandbox/jng/querydef/Common/MdfParser/IOSpatialContextExtent.h
   sandbox/jng/querydef/Common/Schema/QueryDefinition-2.6.0.xsd
   sandbox/jng/querydef/Server/src/Services/Feature/OpExecuteQueryDefinition.cpp
   sandbox/jng/querydef/Server/src/Services/Feature/OpExecuteQueryDefinition.h
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_AggregateCount.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_AggregateSpatialExtents.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicAllElements.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicBarebones.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicMinimal.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicWithExplicitPropertyList.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicWithFilter.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLAggregate.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLBasic.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLWhere.QueryDefinition
   sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLWhereJoin.QueryDefinition
Modified:
   sandbox/jng/querydef/Common/MapGuideCommon/Services/ProxyFeatureService.cpp
   sandbox/jng/querydef/Common/MapGuideCommon/Services/ProxyFeatureService.h
   sandbox/jng/querydef/Common/MdfModel/MdfModel.vcxproj
   sandbox/jng/querydef/Common/MdfModel/MdfModel.vcxproj.filters
   sandbox/jng/querydef/Common/MdfParser/IONameStringPair.cpp
   sandbox/jng/querydef/Common/MdfParser/IONameStringPair.h
   sandbox/jng/querydef/Common/MdfParser/MdfParser.vcxproj
   sandbox/jng/querydef/Common/MdfParser/MdfParser.vcxproj.filters
   sandbox/jng/querydef/Common/MdfParser/SAX2Parser.cpp
   sandbox/jng/querydef/Common/MdfParser/SAX2Parser.h
   sandbox/jng/querydef/Common/PlatformBase/Services/FeatureDefs.h
   sandbox/jng/querydef/Common/PlatformBase/Services/FeatureService.h
   sandbox/jng/querydef/Common/PlatformBase/Services/ResourceDefs.cpp
   sandbox/jng/querydef/Common/PlatformBase/Services/ResourceDefs.h
   sandbox/jng/querydef/Server/src/PostBuild/PostBuild.mak
   sandbox/jng/querydef/Server/src/Services/Feature/FeatureOperationFactory.cpp
   sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.cpp
   sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.h
   sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.vcxproj
   sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.vcxproj.filters
   sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureServiceBuild.cpp
   sandbox/jng/querydef/Server/src/UnitTesting/TestFeatureService.cpp
   sandbox/jng/querydef/Server/src/UnitTesting/TestFeatureService.h
Log:
This submission contains the following changes:

 * Add new QueryDefinition-2.6.0.xsd schema
 * Add new QueryDefinition resource type
 * Implement QueryDefinition in MdfModel and MdfParser
 * Add new API to MgFeatureService:
   * ExecuteQueryDefinition
 * Add our test suite and example query definition resources

So what's left is the actual implementation of this new API :) which our implemented test suite (that's obviously currently failing) should eventually pass with flying colours when implementation is completed.

Modified: sandbox/jng/querydef/Common/MapGuideCommon/Services/ProxyFeatureService.cpp
===================================================================
--- sandbox/jng/querydef/Common/MapGuideCommon/Services/ProxyFeatureService.cpp	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MapGuideCommon/Services/ProxyFeatureService.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -592,6 +592,107 @@
 }
 
 
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+/// a MgFeatureReader containing the query results
+///
+/// \remarks
+/// Any parameters that are defined in the Query Definition will assume default values when calling this overload.
+/// Also be sure to Close() the MgFeatureReader object returned by this method.
+///
+/// <!-- Syntax in .Net, Java, and PHP -->
+/// \htmlinclude DotNetSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+/// \htmlinclude JavaSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+/// \htmlinclude PHPSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+///
+/// \param resource (MgResourceIdentifier)
+/// A resource identifier for the Query Definition
+///
+/// \return
+/// Returns an MgFeatureReader containing the results of the executed query
+///
+MgFeatureReader* MgProxyFeatureService::ExecuteQueryDefinition(MgResourceIdentifier* resource)
+{
+    MgCommand cmd;
+    cmd.ExecuteCommand(m_connProp,                                  // Connection
+                       MgCommand::knObject,                         // Return type expected
+                       MgFeatureServiceOpId::ExecuteQueryDefinition_Id, // Command Code
+                       1,                                           // No of arguments
+                       Feature_Service,                             // Service Id
+                       BUILD_VERSION(2,6,0),                        // Operation version
+                       MgCommand::knObject, resource,               // Argument#1
+                       MgCommand::knNone);                          // End of argument
+
+    SetWarning(cmd.GetWarningObject());
+
+    Ptr<MgProxyFeatureReader> featReader = (MgProxyFeatureReader*)cmd.GetReturnValue().val.m_obj;
+
+    if (featReader != NULL)
+        featReader->SetService(this); // Feature reader on proxy side would store proxy service to call GetFeatures()
+
+    return SAFE_ADDREF((MgProxyFeatureReader*)featReader);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+/// a MgFeatureReader containing the query results
+///
+/// \remarks
+/// Any parameters that are defined in the Query Definition that are not specified in the parameter collection passed in 
+/// will assume default values when calling this overload.
+/// Also be sure to Close() the MgFeatureReader object returned by this method.
+///
+/// <!-- Syntax in .Net, Java, and PHP -->
+/// \htmlinclude DotNetSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+/// \htmlinclude JavaSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+/// \htmlinclude PHPSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+///
+/// \param resource (MgResourceIdentifier)
+/// A resource identifier for the Query Definition
+///
+/// \param parameters (MgPropertyCollection)
+/// A collection of parameters to pass into this query
+///
+/// \return
+/// Returns an MgFeatureReader containing the results of the executed query
+///
+MgFeatureReader* MgProxyFeatureService::ExecuteQueryDefinition(MgResourceIdentifier* resource, MgPropertyCollection* parameters)
+{
+    MgCommand cmd;
+    cmd.ExecuteCommand(m_connProp,                                  // Connection
+                       MgCommand::knObject,                         // Return type expected
+                       MgFeatureServiceOpId::ExecuteQueryDefinition_Id, // Command Code
+                       2,                                           // No of arguments
+                       Feature_Service,                             // Service Id
+                       BUILD_VERSION(2,6,0),                        // Operation version
+                       MgCommand::knObject, resource,               // Argument#1
+                       MgCommand::knObject, parameters,             // Argument#2
+                       MgCommand::knNone);                          // End of argument
+
+    SetWarning(cmd.GetWarningObject());
+
+    Ptr<MgProxyFeatureReader> featReader = (MgProxyFeatureReader*)cmd.GetReturnValue().val.m_obj;
+
+    if (featReader != NULL)
+        featReader->SetService(this); // Feature reader on proxy side would store proxy service to call GetFeatures()
+
+    return SAFE_ADDREF((MgProxyFeatureReader*)featReader);
+}
+
 //////////////////////////////////////////////////////////////////
 /// <summary>
 /// This operation allows user to select features and then combine them into a group (means aggregate them).

Modified: sandbox/jng/querydef/Common/MapGuideCommon/Services/ProxyFeatureService.h
===================================================================
--- sandbox/jng/querydef/Common/MapGuideCommon/Services/ProxyFeatureService.h	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MapGuideCommon/Services/ProxyFeatureService.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -557,6 +557,66 @@
                                             MgFeatureQueryOptions* options,
                                             CREFSTRING coordinateSystem);
 
+    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+    /// a MgFeatureReader containing the query results
+    ///
+    /// \remarks
+    /// Any parameters that are defined in the Query Definition will assume default values when calling this overload.
+    /// Also be sure to Close() the MgFeatureReader object returned by this method.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource (MgResourceIdentifier)
+    /// A resource identifier for the Query Definition
+    ///
+    /// \return
+    /// Returns an MgFeatureReader containing the results of the executed query
+    ///
+    virtual MgFeatureReader* ExecuteQueryDefinition(MgResourceIdentifier* resource);
+
+    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+    /// a MgFeatureReader containing the query results
+    ///
+    /// \remarks
+    /// Any parameters that are defined in the Query Definition that are not specified in the parameter collection passed in 
+    /// will assume default values when calling this overload.
+    /// Also be sure to Close() the MgFeatureReader object returned by this method.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource (MgResourceIdentifier)
+    /// A resource identifier for the Query Definition
+    ///
+    /// \param parameters (MgPropertyCollection)
+    /// A collection of parameters to pass into this query
+    ///
+    /// \return
+    /// Returns an MgFeatureReader containing the results of the executed query
+    ///
+    virtual MgFeatureReader* ExecuteQueryDefinition(MgResourceIdentifier* resource, MgPropertyCollection* parameters);
+
     /////////////////////////////////////////////////////////////////
     /// \brief
     /// This operation allows user to select features and then combine them into a group (means aggregate them).

Added: sandbox/jng/querydef/Common/MdfModel/AggregateQueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/AggregateQueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/AggregateQueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,43 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "BaseSelectQueryDefinition.h"
+#include "AggregateQueryDefinition.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+AggregateQueryDefinition::AggregateQueryDefinition(const MdfString& strResourceID, const MdfString& strFeatureClass)
+    : BaseSelectQueryDefinition(strResourceID, strFeatureClass), m_groupFilter(L"")
+{ }
+
+AggregateQueryDefinition::~AggregateQueryDefinition()
+{ }
+
+StringObjectCollection* AggregateQueryDefinition::GetGrouping()
+{
+    return &this->m_grouping;
+}
+        
+const MdfString& AggregateQueryDefinition::GetGroupFilter() const
+{
+    return this->m_groupFilter;
+}
+
+void AggregateQueryDefinition::SetGroupFilter(const MdfString& strGroupFilter)
+{
+    this->m_groupFilter = strGroupFilter;
+}
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/AggregateQueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/AggregateQueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/AggregateQueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,44 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef AGGREGATEQUERYDEFINITION_H_
+#define AGGREGATEQUERYDEFINITION_H_
+
+#include "BaseSelectQueryDefinition.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    class MDFMODEL_API AggregateQueryDefinition : public BaseSelectQueryDefinition
+    {
+    public:
+        // Construction, destruction, initialization
+        AggregateQueryDefinition(const MdfString& strResourceID, const MdfString& strFeatureClass);
+        virtual ~AggregateQueryDefinition();
+
+        StringObjectCollection* GetGrouping();
+        
+        const MdfString& GetGroupFilter() const;
+        void SetGroupFilter(const MdfString& strGroupFilter);
+    private:
+
+        StringObjectCollection m_grouping;
+        MdfString m_groupFilter;
+    };
+
+END_NAMESPACE_MDFMODEL
+
+#endif //AGGREGATEQUERYDEFINITION_H_
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/BaseSelectQueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/BaseSelectQueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/BaseSelectQueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,75 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "QueryDefinition.h"
+#include "BaseSelectQueryDefinition.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+// Construction, destruction, initialization
+BaseSelectQueryDefinition::BaseSelectQueryDefinition(const MdfString& strResourceID, const MdfString& strFeatureClass)
+    : QueryDefinition(strResourceID), m_featureClass(strFeatureClass), m_filter(L"")
+{ }
+
+BaseSelectQueryDefinition::~BaseSelectQueryDefinition()
+{ }
+
+const MdfString& BaseSelectQueryDefinition::GetFeatureClass() const
+{
+    return this->m_featureClass;
+}
+
+void BaseSelectQueryDefinition::SetFeatureClass(const MdfString& strFeatureClass)
+{
+    this->m_featureClass = strFeatureClass;
+}
+
+// Property : Filter
+const MdfString& BaseSelectQueryDefinition::GetFilter() const
+{
+    return this->m_filter;
+}
+
+void BaseSelectQueryDefinition::SetFilter(const MdfString& strFilter)
+{
+    this->m_filter = strFilter;
+}
+
+StringObjectCollection* BaseSelectQueryDefinition::GetProperties()
+{
+    return &this->m_properties;
+}
+
+NameStringPairCollection* BaseSelectQueryDefinition::GetComputedProperties()
+{
+    return &this->m_computedProperties;
+}
+
+StringObjectCollection* BaseSelectQueryDefinition::GetOrdering()
+{
+    return &this->m_ordering;
+}
+
+BaseSelectQueryDefinition::SelectOrderingType BaseSelectQueryDefinition::GetOrderingOption()
+{
+    return this->m_orderingOption;
+}
+
+void BaseSelectQueryDefinition::SetOrderingOption(BaseSelectQueryDefinition::SelectOrderingType orderingOption)
+{
+    this->m_orderingOption = orderingOption;
+}
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/BaseSelectQueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/BaseSelectQueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/BaseSelectQueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,70 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef BASESELECTQUERYDEFINITION_H_
+#define BASESELECTQUERYDEFINITION_H_
+
+#include "QueryDefinition.h"
+#include "NameStringPair.h"
+#include "Common/StringObject.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    class MDFMODEL_API BaseSelectQueryDefinition : public QueryDefinition
+    {
+    public:
+        enum SelectOrderingType
+        {
+            Ascending,
+            Descending
+        };
+
+        // Construction, destruction, initialization
+        BaseSelectQueryDefinition(const MdfString& strResourceID, const MdfString& strFeatureClass);
+        virtual ~BaseSelectQueryDefinition();
+
+        // Operations
+        // Property : FeatureClass
+        const MdfString& GetFeatureClass() const;
+        void SetFeatureClass(const MdfString&  strFeatureClass);
+
+        // Property : Filter
+        const MdfString& GetFilter() const;
+        void SetFilter(const MdfString& strFilter);
+
+        StringObjectCollection* GetProperties();
+
+        NameStringPairCollection* GetComputedProperties();
+
+        StringObjectCollection* GetOrdering();
+
+        SelectOrderingType GetOrderingOption();
+        void SetOrderingOption(SelectOrderingType orderingOption);
+
+    private:
+
+        MdfString m_featureClass;
+        MdfString m_filter;
+
+        StringObjectCollection m_properties;
+        NameStringPairCollection m_computedProperties;
+        StringObjectCollection m_ordering;
+        SelectOrderingType m_orderingOption;
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif //BASESELECTQUERYDEFINITION_H_
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/FeatureQueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/FeatureQueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/FeatureQueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,27 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "BaseSelectQueryDefinition.h"
+#include "FeatureQueryDefinition.h"
+
+// Construction, destruction, initialization
+FeatureQueryDefinition::FeatureQueryDefinition(const MdfString& strResourceID, const MdfString& strFeatureClass)
+    : BaseSelectQueryDefinition(strResourceID, strFeatureClass)
+{ }
+
+FeatureQueryDefinition::~FeatureQueryDefinition()
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/FeatureQueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/FeatureQueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/FeatureQueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,38 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef FEATUREQUERYDEFINITION_H_
+#define FEATUREQUERYDEFINITION_H_
+
+#include "BaseSelectQueryDefinition.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    class MDFMODEL_API FeatureQueryDefinition : public BaseSelectQueryDefinition
+    {
+    public:
+        // Construction, destruction, initialization
+        FeatureQueryDefinition(const MdfString& strResourceID, const MdfString& strFeatureClass);
+        virtual ~FeatureQueryDefinition();
+
+
+    private:
+    };
+
+END_NAMESPACE_MDFMODEL
+
+#endif //FEATUREQUERYDEFINITION_H_
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/GeometryInfo.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/GeometryInfo.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/GeometryInfo.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,146 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "GeometryInfo.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+GeometryInfo::GeometryInfo(const MdfString& strGeometry, const int& iGeomTypes)
+    : m_geometry(strGeometry), m_geometryTypes(iGeomTypes)
+{ }
+
+GeometryInfo::~GeometryInfo()
+{ }
+
+const MdfString& GeometryInfo::GetGeometry() const
+{
+    return this->m_geometry;
+}
+
+void GeometryInfo::SetGeometry(const MdfString& strGeometry)
+{
+    this->m_geometry = strGeometry;
+}
+
+int GeometryInfo::GetGeometryTypes() const
+{
+    return this->m_geometryTypes;
+}
+
+void GeometryInfo::SetGeometryTypes(const int& iGeomTypes)
+{
+    this->m_geometryTypes = iGeomTypes;
+}
+
+const MdfString& GeometryInfo::GetSpatialContextName() const
+{
+    return this->m_scName;
+}
+
+void GeometryInfo::SetSpatialContextName(const MdfString& strName)
+{
+    this->m_scName = strName;
+}
+
+const MdfString& GeometryInfo::GetSpatialContextDescription() const
+{
+    return this->m_scDescription;
+}
+
+void GeometryInfo::SetSpatialContextDescription(const MdfString& strDescription)
+{
+    this->m_scDescription = strDescription;
+}
+
+const MdfString& GeometryInfo::GetCoordinateSystemName() const
+{
+    return this->m_csName;
+}
+
+void GeometryInfo::SetCoordinateSystemName(const MdfString& strCoordSysName)
+{
+    this->m_csName = strCoordSysName;
+}
+
+const MdfString& GeometryInfo::GetCoordinateSystemWkt() const
+{
+    return this->m_csWkt;
+}
+
+void GeometryInfo::SetCoordinateSystemWkt(const MdfString& strCoordSysWkt)
+{
+    this->m_csWkt = strCoordSysWkt;
+}
+
+GeometryInfo::SpatialContextExtentType GeometryInfo::GetSpatialContextExtentType() const
+{
+    return this->m_extentType;
+}
+
+void GeometryInfo::SetSpatialContextExtentType(GeometryInfo::SpatialContextExtentType scType)
+{
+    this->m_extentType = scType;
+}
+
+SpatialContextCoordinate* GeometryInfo::GetSpatialContextLowerLeftCoordinate()
+{
+    return this->m_lowerLeftCoordinate;
+}
+
+void GeometryInfo::AdoptSpatialContextLowerLeftCoordinate(SpatialContextCoordinate* coordinate)
+{
+    if (this->m_lowerLeftCoordinate != coordinate)
+    {
+        delete this->m_lowerLeftCoordinate;
+        this->m_lowerLeftCoordinate = coordinate;
+    }
+}
+
+SpatialContextCoordinate* GeometryInfo::GetSpatialContextUpperRightCoordinate()
+{
+    return this->m_upperRightCoordinate;
+}
+
+void GeometryInfo::AdoptSpatialContextUpperRightCoordinate(SpatialContextCoordinate* coordinate)
+{
+     if (this->m_upperRightCoordinate != coordinate)
+    {
+        delete this->m_upperRightCoordinate;
+        this->m_upperRightCoordinate = coordinate;
+    }
+}
+
+double GeometryInfo::GetSpatialContextXYTolerance() const
+{
+    return m_xyTolerance;
+}
+
+void GeometryInfo::SetSpatialContextXYTolerance(const double& dXYTolerance)
+{
+    this->m_xyTolerance = dXYTolerance;
+}
+
+double GeometryInfo::GetSpatialContextZTolerance() const
+{
+    return m_zTolerance;
+}
+
+void GeometryInfo::SetSpatialContextZTolerance(const double& dZTolerance)
+{
+    m_zTolerance = dZTolerance;
+}
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/GeometryInfo.h
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/GeometryInfo.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/GeometryInfo.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,121 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef GEOMETRYINFO_H_
+#define GEOMETRYINFO_H_
+
+#include "MdfModel.h"
+#include "MdfRootObject.h"
+#include "Box2D.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    class MDFMODEL_API SpatialContextCoordinate
+    {
+    public:
+        SpatialContextCoordinate() : m_x(0.0), m_y(0.0), m_z(0.0), m_m(0.0)
+        { }
+
+        SpatialContextCoordinate(const double& x, const double& y)
+            : m_x(x), m_y(y), m_z(0.0), m_m(0.0)
+        { }
+
+        SpatialContextCoordinate(const double& x, const double& y, const double& z, const double& m)
+            : m_x(x), m_y(y), m_z(z), m_m(m)
+        { }
+
+        double GetX() const { return m_x; }
+        void SetX(const double& value) { m_x = value; }
+
+        double GetY() const { return m_y; }
+        void SetY(const double& value) { m_y = value; }
+
+        double GetZ() const { return m_z; }
+        void SetZ(const double& value) { m_z = value; }
+
+        double GetM() const { return m_m; }
+        void SetM(const double& value) { m_m = value; }
+
+    private:
+        double m_x;
+        double m_y;
+        double m_z;
+        double m_m;
+    };
+
+    class MDFMODEL_API GeometryInfo : public MdfRootObject
+    {
+    public:
+        enum SpatialContextExtentType
+        {
+            Static,
+            Dynamic
+        };
+
+        GeometryInfo(const MdfString& strGeometry, const int& iGeomTypes);
+        virtual ~GeometryInfo();
+
+        const MdfString& GetGeometry() const;
+        void SetGeometry(const MdfString& strGeometry);
+
+        int GetGeometryTypes() const;
+        void SetGeometryTypes(const int& iGeomTypes);
+
+        const MdfString& GetSpatialContextName() const;
+        void SetSpatialContextName(const MdfString& strName);
+
+        const MdfString& GetSpatialContextDescription() const;
+        void SetSpatialContextDescription(const MdfString& strDescription);
+
+        const MdfString& GetCoordinateSystemName() const;
+        void SetCoordinateSystemName(const MdfString& strCoordSysName);
+
+        const MdfString& GetCoordinateSystemWkt() const;
+        void SetCoordinateSystemWkt(const MdfString& strCoordSysWkt);
+
+        SpatialContextExtentType GetSpatialContextExtentType() const;
+        void SetSpatialContextExtentType(SpatialContextExtentType scType);
+
+        SpatialContextCoordinate* GetSpatialContextLowerLeftCoordinate();
+        void AdoptSpatialContextLowerLeftCoordinate(SpatialContextCoordinate* coordinate);
+
+        SpatialContextCoordinate* GetSpatialContextUpperRightCoordinate();
+        void AdoptSpatialContextUpperRightCoordinate(SpatialContextCoordinate* coordinate);
+
+        double GetSpatialContextXYTolerance() const;
+        void SetSpatialContextXYTolerance(const double& dXYTolerance);
+
+        double GetSpatialContextZTolerance() const;
+        void SetSpatialContextZTolerance(const double& dZTolerance);
+
+    private:
+        MdfString m_geometry;
+        int m_geometryTypes;
+        MdfString m_scName;
+        MdfString m_scDescription;
+        MdfString m_csName;
+        MdfString m_csWkt;
+        SpatialContextExtentType m_extentType;
+        SpatialContextCoordinate* m_lowerLeftCoordinate;
+        SpatialContextCoordinate* m_upperRightCoordinate;
+        double m_xyTolerance;
+        double m_zTolerance;
+    };
+
+END_NAMESPACE_MDFMODEL
+
+#endif //GEOMETRYINFO_H_
\ No newline at end of file

Modified: sandbox/jng/querydef/Common/MdfModel/MdfModel.vcxproj
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/MdfModel.vcxproj	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MdfModel/MdfModel.vcxproj	2013-04-30 15:21:47 UTC (rev 7465)
@@ -192,8 +192,12 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="AggregateQueryDefinition.cpp" />
     <ClCompile Include="AreaUsage.cpp" />
+    <ClCompile Include="BaseSelectQueryDefinition.cpp" />
     <ClCompile Include="CompoundSymbolDefinition.cpp" />
+    <ClCompile Include="FeatureQueryDefinition.cpp" />
+    <ClCompile Include="GeometryInfo.cpp" />
     <ClCompile Include="GraphicElement.cpp" />
     <ClCompile Include="Image.cpp" />
     <ClCompile Include="LineUsage.cpp" />
@@ -209,10 +213,13 @@
     <ClCompile Include="ProfileRenderWatermarkResult.cpp" />
     <ClCompile Include="ProfileRenderWatermarksResult.cpp" />
     <ClCompile Include="ProfileResult.cpp" />
+    <ClCompile Include="QueryDefinition.cpp" />
+    <ClCompile Include="QueryParameter.cpp" />
     <ClCompile Include="ResizeBox.cpp" />
     <ClCompile Include="ScaleRange.cpp" />
     <ClCompile Include="SimpleSymbol.cpp" />
     <ClCompile Include="SimpleSymbolDefinition.cpp" />
+    <ClCompile Include="SQLQueryDefinition.cpp" />
     <ClCompile Include="SymbolDefinition.cpp" />
     <ClCompile Include="Text.cpp" />
     <ClCompile Include="TextFrame.cpp" />
@@ -305,8 +312,12 @@
     <ClCompile Include="Version.cpp" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="AggregateQueryDefinition.h" />
     <ClInclude Include="AreaUsage.h" />
+    <ClInclude Include="BaseSelectQueryDefinition.h" />
     <ClInclude Include="CompoundSymbolDefinition.h" />
+    <ClInclude Include="FeatureQueryDefinition.h" />
+    <ClInclude Include="GeometryInfo.h" />
     <ClInclude Include="GraphicElement.h" />
     <ClInclude Include="IGraphicElementVisitor.h" />
     <CustomBuildStep Include="Image.h" />
@@ -324,10 +335,13 @@
     <ClInclude Include="ProfileRenderWatermarkResult.h" />
     <ClInclude Include="ProfileRenderWatermarksResult.h" />
     <ClInclude Include="ProfileResult.h" />
+    <ClInclude Include="QueryDefinition.h" />
+    <ClInclude Include="QueryParameter.h" />
     <ClInclude Include="ResizeBox.h" />
     <ClInclude Include="ScaleRange.h" />
     <ClInclude Include="SimpleSymbol.h" />
     <ClInclude Include="SimpleSymbolDefinition.h" />
+    <ClInclude Include="SQLQueryDefinition.h" />
     <ClInclude Include="SymbolDefinition.h" />
     <CustomBuildStep Include="Text.h" />
     <ClInclude Include="TextFrame.h" />

Modified: sandbox/jng/querydef/Common/MdfModel/MdfModel.vcxproj.filters
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/MdfModel.vcxproj.filters	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MdfModel/MdfModel.vcxproj.filters	2013-04-30 15:21:47 UTC (rev 7465)
@@ -40,6 +40,9 @@
     <Filter Include="ProfileResult">
       <UniqueIdentifier>{e2817956-7222-40f0-93fd-d3fc5ad63418}</UniqueIdentifier>
     </Filter>
+    <Filter Include="QueryDefinition">
+      <UniqueIdentifier>{4d8c8ed5-8c2b-4497-9be2-3dff81553743}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="AreaUsage.cpp">
@@ -355,6 +358,27 @@
     <ClCompile Include="ProfileRenderSelectionResult.cpp">
       <Filter>ProfileResult</Filter>
     </ClCompile>
+    <ClCompile Include="QueryDefinition.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="GeometryInfo.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="QueryParameter.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="SQLQueryDefinition.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="AggregateQueryDefinition.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="FeatureQueryDefinition.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="BaseSelectQueryDefinition.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="AreaUsage.h">
@@ -686,6 +710,27 @@
     <ClInclude Include="ProfileRenderLayersResultBase.h">
       <Filter>ProfileResult</Filter>
     </ClInclude>
+    <ClInclude Include="QueryDefinition.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="GeometryInfo.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="BaseSelectQueryDefinition.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="FeatureQueryDefinition.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="AggregateQueryDefinition.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="SQLQueryDefinition.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="QueryParameter.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="MdfModel.rc" />

Added: sandbox/jng/querydef/Common/MdfModel/QueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/QueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/QueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,61 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "stdafx.h"
+#include "QueryDefinition.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+QueryDefinition::QueryDefinition(const MdfString& strResourceID)
+    : m_strResourceID(strResourceID), m_geomInfo(NULL)
+{ }
+
+QueryDefinition::~QueryDefinition() { }
+
+const MdfString& QueryDefinition::GetResourceID() const
+{
+    return this->m_strResourceID;
+}
+
+void QueryDefinition::SetResourceID(const MdfString& strResourceID)
+{
+    this->m_strResourceID = strResourceID;
+}
+
+StringObjectCollection* QueryDefinition::GetIdentityProperties()
+{
+    return &this->m_identityProperties;
+}
+        
+QueryParameterCollection* QueryDefinition::GetParameters()
+{
+    return &this->m_parameters;
+}
+
+GeometryInfo* QueryDefinition::GetGeometryInfo()
+{
+    return this->m_geomInfo;
+}
+
+void QueryDefinition::AdoptGeometryInfo(GeometryInfo* geomInfo)
+{
+    if (this->m_geomInfo != geomInfo)
+    {
+        delete this->m_geomInfo;
+        this->m_geomInfo = geomInfo;
+    }
+}
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/QueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/QueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/QueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,59 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef QUERYDEFINITION_H_
+#define QUERYDEFINITION_H_
+
+#include "MdfModel.h"
+#include "MdfRootObject.h"
+#include "QueryParameter.h"
+#include "GeometryInfo.h"
+#include "Common/StringObject.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    class MDFMODEL_API QueryDefinition : public MdfRootObject
+    {
+    public:
+        // Construction, destruction, initialization
+        QueryDefinition(const MdfString& strResourceID);
+        virtual ~QueryDefinition();
+
+        // Operations
+        // Property : ResourceID
+        const MdfString& GetResourceID() const;
+        void SetResourceID(const MdfString& strResourceID);
+
+        StringObjectCollection* GetIdentityProperties();
+        
+        QueryParameterCollection* GetParameters();
+
+        GeometryInfo* GetGeometryInfo();
+        void AdoptGeometryInfo(GeometryInfo* geomInfo);
+
+    private:
+        // Data members
+        // The ID of the DataSource used by this query
+        MdfString m_strResourceID;
+
+        StringObjectCollection m_identityProperties;
+        QueryParameterCollection m_parameters;
+        GeometryInfo* m_geomInfo;
+    }; 
+
+END_NAMESPACE_MDFMODEL
+#endif //QUERYDEFINITION_H_
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/QueryParameter.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/QueryParameter.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/QueryParameter.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,57 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "QueryParameter.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+QueryParameter::QueryParameter(const MdfString& strName, QueryParameterDataType dataType, const MdfString& defaultValue)
+    : m_name(strName), m_dataType(dataType), m_defaultValue(defaultValue)
+{ }
+
+QueryParameter::~QueryParameter()
+{ }
+
+const MdfString& QueryParameter::GetName() const
+{
+    return this->m_name;
+}
+
+void QueryParameter::SetName(const MdfString& strName)
+{
+    this->m_name = strName;
+}
+
+QueryParameter::QueryParameterDataType QueryParameter::GetParameterType() const
+{
+    return this->m_dataType;
+}
+
+void QueryParameter::SetParameterType(QueryParameter::QueryParameterDataType dataType)
+{
+    this->m_dataType = dataType;
+}
+
+const MdfString& QueryParameter::GetDefaultValue() const
+{
+    return this->m_defaultValue;
+}
+
+void QueryParameter::SetDefaultValue(const MdfString& strDefaultValue)
+{
+    this->m_defaultValue = strDefaultValue;
+}
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/QueryParameter.h
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/QueryParameter.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/QueryParameter.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,68 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef QUERYPARAMETER_H_
+#define QUERYPARAMETER_H_
+
+#include "MdfModel.h"
+#include "MdfOwnerCollection.h"
+#include "MdfRootObject.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    class MDFMODEL_API QueryParameter : public MdfRootObject
+    {
+    public:
+        enum QueryParameterDataType
+        {
+            Boolean,
+            Byte,
+            DateTime,
+            Double,
+            Int16,
+            Int32,
+            Int64,
+            Single,
+            String,
+            Geometry
+        };
+
+        QueryParameter(const MdfString& strName, QueryParameterDataType dataType, const MdfString& defaultValue);
+        virtual ~QueryParameter();
+
+        const MdfString& GetName() const;
+        void SetName(const MdfString& strName);
+
+        QueryParameterDataType GetParameterType() const;
+        void SetParameterType(QueryParameterDataType dataType);
+
+        const MdfString& GetDefaultValue() const;
+        void SetDefaultValue(const MdfString& strDefaultValue);
+
+    private:
+
+        MdfString m_name;
+        QueryParameterDataType m_dataType;
+        MdfString m_defaultValue;
+    };
+
+    typedef MdfOwnerCollection<QueryParameter> QueryParameterCollection;
+    EXPIMP_TEMPLATE template class MDFMODEL_API MdfOwnerCollection<QueryParameter>;
+
+END_NAMESPACE_MDFMODEL
+
+#endif //QUERYPARAMETER_H_
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/SQLQueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/SQLQueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/SQLQueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,37 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "SQLQueryDefinition.h"
+
+using namespace MDFMODEL_NAMESPACE;
+
+SQLQueryDefinition::SQLQueryDefinition(const MdfString& strResourceID)
+    : QueryDefinition(strResourceID), m_sql(L"")
+{ }
+
+SQLQueryDefinition::~SQLQueryDefinition()
+{ }
+
+const MdfString& SQLQueryDefinition::GetSQL() const
+{
+    return this->m_sql;
+}
+
+void SQLQueryDefinition::SetSQL(const MdfString& strSQL)
+{
+    this->m_sql = strSQL;
+}
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfModel/SQLQueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Common/MdfModel/SQLQueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfModel/SQLQueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,41 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef SQLQUERYDEFINITION_H_
+#define SQLQUERYDEFINITION_H_
+
+#include "QueryDefinition.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    class MDFMODEL_API SQLQueryDefinition : public QueryDefinition
+    {
+    public:
+        // Construction, destruction, initialization
+        SQLQueryDefinition(const MdfString& strResourceID);
+        virtual ~SQLQueryDefinition();
+
+        const MdfString& GetSQL() const;
+        void SetSQL(const MdfString& strSQL);
+
+    private:
+        MdfString m_sql;
+    };
+
+END_NAMESPACE_MDFMODEL
+
+#endif //SQLQUERYDEFINITION_H_
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOAggregateQueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOAggregateQueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOAggregateQueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,172 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOAggregateQueryDefinition.h"
+#include "IONameStringPair.h"
+#include "IOGeometryInfo.h"
+#include "IOQueryParameter.h"
+#include "Common/IOStringObjectCollection.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, AggregateQueryDefinition);
+ELEM_MAP_ENTRY(2, ResourceId);
+ELEM_MAP_ENTRY(3, GeometryInfo);
+ELEM_MAP_ENTRY(4, IdentityProperties);
+ELEM_MAP_ENTRY(5, Parameters);
+ELEM_MAP_ENTRY(6, FeatureClass);
+ELEM_MAP_ENTRY(7, Filter);
+ELEM_MAP_ENTRY(8, Properties);
+ELEM_MAP_ENTRY(9, ComputedProperties);
+ELEM_MAP_ENTRY(10, OrderBy);
+ELEM_MAP_ENTRY(11, Ordering);
+ELEM_MAP_ENTRY(12, ExtendedData1);
+
+IOAggregateQueryDefinition::IOAggregateQueryDefinition(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_query = NULL;
+}
+
+IOAggregateQueryDefinition::IOAggregateQueryDefinition(AggregateQueryDefinition* query, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_query = query;
+}
+
+IOAggregateQueryDefinition::~IOAggregateQueryDefinition()
+{ }
+
+void IOAggregateQueryDefinition::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eAggregateQueryDefinition:
+        this->m_startElemName = name;
+        break;
+
+    case eGeometryInfo:
+        {
+            GeometryInfo* geom = this->m_query->GetGeometryInfo();
+            IOGeometryInfo* IO = new IOGeometryInfo(geom, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eIdentityProperties:
+        {
+            StringObjectCollection* props = this->m_query->GetIdentityProperties();
+            IOStringObjectCollection* IO = new IOStringObjectCollection(props, this->m_version, "IdentityProperties", "Property"); //NOXLATE
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eParameters:
+        {
+            QueryParameterCollection* queryParams = this->m_query->GetParameters();
+            IOQueryParameter* IO = new IOQueryParameter(queryParams, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eProperties:
+        { 
+            StringObjectCollection* props = this->m_query->GetProperties();
+            IOStringObjectCollection* IO = new IOStringObjectCollection(props, this->m_version, "Properties", "Property"); //NOXLATE
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eComputedProperties:
+        {
+            IONameStringPair* IO = new IONameStringPair(this->m_query, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eOrderBy:
+        {
+            StringObjectCollection* props = this->m_query->GetOrdering();
+            IOStringObjectCollection* IO = new IOStringObjectCollection(props, this->m_version, "OrderBy", "Property"); //NOXLATE
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eExtendedData1:
+        this->m_procExtData = true;
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOAggregateQueryDefinition::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eResourceId:
+        this->m_query->SetResourceID(ch);
+        break;
+
+    case eFeatureClass:
+        this->m_query->SetFeatureClass(ch);
+        break;
+
+    case eFilter:
+        this->m_query->SetFilter(ch);
+        break;
+
+    case eOrdering:
+        if (::wcscmp(ch, L"Ascending") == 0) // NOXLATE
+            this->m_query->SetOrderingOption(BaseSelectQueryDefinition::Ascending);
+        else if (::wcscmp(ch, L"Descending") == 0) // NOXLATE
+            this->m_query->SetOrderingOption(BaseSelectQueryDefinition::Descending);
+        break;
+    }
+}
+
+void IOAggregateQueryDefinition::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_query->SetUnknownXml(this->m_unknownXml);
+
+        this->m_query = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+    else if (eExtendedData1 == _ElementIdFromName(name))
+    {
+        this->m_procExtData = false;
+    }
+}
+
+void IOAggregateQueryDefinition::Write(MdfStream& fd, AggregateQueryDefinition* query, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOAggregateQueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOAggregateQueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOAggregateQueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,47 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOAGGREGATEQUERYDEFINITION_H
+#define _IOAGGREGATEQUERYDEFINITION_H
+
+#include "SAX2ElementHandler.h"
+#include "AggregateQueryDefinition.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOAggregateQueryDefinition : public SAX2ElementHandler
+{
+    public:
+        IOAggregateQueryDefinition(Version& version);
+        IOAggregateQueryDefinition(AggregateQueryDefinition* query, Version& version);
+        virtual ~IOAggregateQueryDefinition();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, AggregateQueryDefinition* query, Version* version, MgTab& tab);
+
+    private:
+        AggregateQueryDefinition* m_query;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOAGGREGATEQUERYDEFINITION_H
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOFeatureQueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOFeatureQueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOFeatureQueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,172 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOFeatureQueryDefinition.h"
+#include "IONameStringPair.h"
+#include "IOGeometryInfo.h"
+#include "IOQueryParameter.h"
+#include "Common/IOStringObjectCollection.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, FeatureQueryDefinition);
+ELEM_MAP_ENTRY(2, ResourceId);
+ELEM_MAP_ENTRY(3, GeometryInfo);
+ELEM_MAP_ENTRY(4, IdentityProperties);
+ELEM_MAP_ENTRY(5, Parameters);
+ELEM_MAP_ENTRY(6, FeatureClass);
+ELEM_MAP_ENTRY(7, Filter);
+ELEM_MAP_ENTRY(8, Properties);
+ELEM_MAP_ENTRY(9, ComputedProperties);
+ELEM_MAP_ENTRY(10, OrderBy);
+ELEM_MAP_ENTRY(11, Ordering);
+ELEM_MAP_ENTRY(12, ExtendedData1);
+
+IOFeatureQueryDefinition::IOFeatureQueryDefinition(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_query = NULL;
+}
+
+IOFeatureQueryDefinition::IOFeatureQueryDefinition(FeatureQueryDefinition* query, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_query = query;
+}
+
+IOFeatureQueryDefinition::~IOFeatureQueryDefinition()
+{ }
+
+void IOFeatureQueryDefinition::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eFeatureQueryDefinition:
+        this->m_startElemName = name;
+        break;
+
+    case eGeometryInfo:
+        {
+            GeometryInfo* geom = this->m_query->GetGeometryInfo();
+            IOGeometryInfo* IO = new IOGeometryInfo(geom, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eIdentityProperties:
+        {
+            StringObjectCollection* props = this->m_query->GetIdentityProperties();
+            IOStringObjectCollection* IO = new IOStringObjectCollection(props, this->m_version, "IdentityProperties", "Property"); //NOXLATE
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eParameters:
+        {
+            QueryParameterCollection* queryParams = this->m_query->GetParameters();
+            IOQueryParameter* IO = new IOQueryParameter(queryParams, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eProperties:
+        { 
+            StringObjectCollection* props = this->m_query->GetProperties();
+            IOStringObjectCollection* IO = new IOStringObjectCollection(props, this->m_version, "Properties", "Property"); //NOXLATE
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eComputedProperties:
+        {
+            IONameStringPair* IO = new IONameStringPair(this->m_query, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eOrderBy:
+        {
+            StringObjectCollection* props = this->m_query->GetOrdering();
+            IOStringObjectCollection* IO = new IOStringObjectCollection(props, this->m_version, "OrderBy", "Property"); //NOXLATE
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eExtendedData1:
+        this->m_procExtData = true;
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOFeatureQueryDefinition::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eResourceId:
+        this->m_query->SetResourceID(ch);
+        break;
+
+    case eFeatureClass:
+        this->m_query->SetFeatureClass(ch);
+        break;
+
+    case eFilter:
+        this->m_query->SetFilter(ch);
+        break;
+
+    case eOrdering:
+        if (::wcscmp(ch, L"Ascending") == 0) // NOXLATE
+            this->m_query->SetOrderingOption(BaseSelectQueryDefinition::Ascending);
+        else if (::wcscmp(ch, L"Descending") == 0) // NOXLATE
+            this->m_query->SetOrderingOption(BaseSelectQueryDefinition::Descending);
+        break;
+    }
+}
+
+void IOFeatureQueryDefinition::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_query->SetUnknownXml(this->m_unknownXml);
+
+        this->m_query = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+    else if (eExtendedData1 == _ElementIdFromName(name))
+    {
+        this->m_procExtData = false;
+    }
+}
+
+void IOFeatureQueryDefinition::Write(MdfStream& fd, FeatureQueryDefinition* query, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOFeatureQueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOFeatureQueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOFeatureQueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,47 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOFEATUREQUERYDEFINITION_H
+#define _IOFEATUREQUERYDEFINITION_H
+
+#include "SAX2ElementHandler.h"
+#include "FeatureQueryDefinition.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOFeatureQueryDefinition : public SAX2ElementHandler
+{
+    public:
+        IOFeatureQueryDefinition(Version& version);
+        IOFeatureQueryDefinition(FeatureQueryDefinition* query, Version& version);
+        virtual ~IOFeatureQueryDefinition();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, FeatureQueryDefinition* query, Version* version, MgTab& tab);
+
+    private:
+        FeatureQueryDefinition* m_query;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOFEATUREQUERYDEFINITION_H
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOGeometryInfo.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOGeometryInfo.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOGeometryInfo.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,89 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOGeometryInfo.h"
+#include "IOSpatialContext.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, GeometryInfo);
+ELEM_MAP_ENTRY(2, Geometry);
+ELEM_MAP_ENTRY(3, GeometryTypes);
+ELEM_MAP_ENTRY(4, SpatialContext);
+
+IOGeometryInfo::IOGeometryInfo(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_geom = NULL;
+}
+
+IOGeometryInfo::IOGeometryInfo(GeometryInfo* geom, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_geom = geom;
+}
+
+IOGeometryInfo::~IOGeometryInfo() 
+{ }
+
+void IOGeometryInfo::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eGeometryInfo:
+        this->m_startElemName = name;
+        break;
+
+    case eSpatialContext:
+        {
+            IOSpatialContext* IO = new IOSpatialContext(this->m_geom, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOGeometryInfo::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eGeometry:
+        this->m_geom->SetGeometry(ch);
+        break;
+
+    case eGeometryTypes:
+        this->m_geom->SetGeometryTypes(wstrToInt(ch));
+        break;
+    }
+}
+
+void IOGeometryInfo::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+
+}
+
+void IOGeometryInfo::Write(MdfStream& fd, GeometryInfo* geom, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOGeometryInfo.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOGeometryInfo.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOGeometryInfo.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,47 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOGEOMETRYINFO_H
+#define _IOGEOMETRYINFO_H
+
+#include "SAX2ElementHandler.h"
+#include "GeometryInfo.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOGeometryInfo : public SAX2ElementHandler
+{
+    public:
+        IOGeometryInfo(Version& version);
+        IOGeometryInfo(GeometryInfo* geom, Version& version);
+        virtual ~IOGeometryInfo();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, GeometryInfo* geom, Version* version, MgTab& tab);
+
+    private:
+        GeometryInfo* m_geom;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOGEOMETRYINFO_H
\ No newline at end of file

Modified: sandbox/jng/querydef/Common/MdfParser/IONameStringPair.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IONameStringPair.cpp	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MdfParser/IONameStringPair.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -34,6 +34,7 @@
     this->m_featureSource = NULL;
     this->m_nameStringPair = NULL;
     this->m_layer = NULL;
+    this->m_query = NULL;
     this->m_overrides = NULL;
 }
 
@@ -43,15 +44,27 @@
     this->m_featureSource = NULL;
     this->m_nameStringPair = NULL;
     this->m_layer = layer;
+    this->m_query = NULL;
     this->m_overrides = NULL;
 }
 
 
+IONameStringPair::IONameStringPair(BaseSelectQueryDefinition* query, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_featureSource = NULL;
+    this->m_nameStringPair = NULL;
+    this->m_layer = NULL;
+    this->m_query = query;
+    this->m_overrides = NULL;
+}
+
+
 IONameStringPair::IONameStringPair(FeatureSource* featureSource, Version& version) : SAX2ElementHandler(version)
 {
     this->m_featureSource = featureSource;
     this->m_nameStringPair = NULL;
     this->m_layer = NULL;
+    this->m_query = NULL;
     this->m_overrides = NULL;
 }
 
@@ -98,6 +111,22 @@
             ParseUnknownXml(name, handlerStack);
         }
     }
+    else if (this->m_query)
+    {
+        if (this->m_currElemName == L"ComputedProperty") // NOXLATE
+        {
+            this->m_startElemName = name;
+            this->m_nameStringPair = new NameStringPair();
+        }
+        else if (this->m_currElemId == eExtendedData1)
+        {
+            this->m_procExtData = true;
+        }
+        else if (this->m_currElemId == eUnknown)
+        {
+            ParseUnknownXml(name, handlerStack);
+        }
+    }
 }
 
 
@@ -126,8 +155,11 @@
             this->m_layer->GetPropertyMappings()->Adopt(this->m_nameStringPair);
         else if (this->m_featureSource)
             this->m_featureSource->GetParameters()->Adopt(this->m_nameStringPair);
+        else if (this->m_query)
+            this->m_query->GetComputedProperties()->Adopt(this->m_nameStringPair);
 
         this->m_layer = NULL;
+        this->m_query = NULL;
         this->m_featureSource = NULL;
         this->m_nameStringPair = NULL;
         this->m_startElemName = L"";

Modified: sandbox/jng/querydef/Common/MdfParser/IONameStringPair.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IONameStringPair.h	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MdfParser/IONameStringPair.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -21,6 +21,7 @@
 #include "SAX2ElementHandler.h"
 #include "NameStringPair.h"
 #include "VectorLayerDefinition.h"
+#include "BaseSelectQueryDefinition.h"
 #include "FeatureSource.h"
 #include "Version.h"
 
@@ -34,6 +35,7 @@
     public:
         IONameStringPair(Version& version);
         IONameStringPair(VectorLayerDefinition* layer, Version& version);
+        IONameStringPair(BaseSelectQueryDefinition* query, Version& version);
         IONameStringPair(FeatureSource* featureSource, Version& version);
         virtual ~IONameStringPair();
 
@@ -46,6 +48,7 @@
     private:
         NameStringPair* m_nameStringPair;
         VectorLayerDefinition* m_layer;
+        BaseSelectQueryDefinition* m_query;
         FeatureSource* m_featureSource;
         NameStringPairCollection* m_overrides;
 };

Added: sandbox/jng/querydef/Common/MdfParser/IOQueryParameter.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOQueryParameter.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOQueryParameter.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,115 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOGeometryInfo.h"
+#include "IOQueryParameter.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, Parameter);
+ELEM_MAP_ENTRY(2, Name);
+ELEM_MAP_ENTRY(3, Type);
+ELEM_MAP_ENTRY(4, DefaultValue);
+
+IOQueryParameter::IOQueryParameter(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_params = NULL;
+    this->m_param = NULL;
+}
+
+IOQueryParameter::IOQueryParameter(QueryParameterCollection* param, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_params = param;
+    this->m_param = NULL;
+}
+
+IOQueryParameter::~IOQueryParameter()
+{ }
+
+void IOQueryParameter::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eParameter:
+        this->m_startElemName = name;
+        this->m_param = new QueryParameter(L"", QueryParameter::String, L"");
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOQueryParameter::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eName:
+        this->m_param->SetName(ch);
+        break;
+
+    case eType:
+        if (::wcscmp(ch, L"Boolean") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::Boolean);
+        else if (::wcscmp(ch, L"Byte") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::Byte);
+        else if (::wcscmp(ch, L"DateTime") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::DateTime);
+        else if (::wcscmp(ch, L"Double") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::Double);
+        else if (::wcscmp(ch, L"Geometry") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::Geometry);
+        else if (::wcscmp(ch, L"Int16") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::Int16);
+        else if (::wcscmp(ch, L"Int32") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::Int32);
+        else if (::wcscmp(ch, L"Int64") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::Int64);
+        else if (::wcscmp(ch, L"Single") == 0) // NOXLATE
+            this->m_param->SetParameterType(QueryParameter::Single);
+        break;
+
+    case eDefaultValue:
+        this->m_param->SetDefaultValue(ch);
+        break;
+    }
+}
+
+void IOQueryParameter::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_param->SetUnknownXml(this->m_unknownXml);
+        this->m_params->Adopt(this->m_param);
+
+        this->m_params = NULL;
+        this->m_param = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+void IOQueryParameter::Write(MdfStream& fd, QueryParameter* param, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOQueryParameter.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOQueryParameter.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOQueryParameter.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOQUERYPARAMETER_H
+#define _IOQUERYPARAMETER_H
+
+#include "SAX2ElementHandler.h"
+#include "QueryParameter.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOQueryParameter : public SAX2ElementHandler
+{
+    public:
+        IOQueryParameter(Version& version);
+        IOQueryParameter(QueryParameterCollection* params, Version& version);
+        virtual ~IOQueryParameter();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, QueryParameter* param, Version* version, MgTab& tab);
+
+    private:
+        QueryParameterCollection* m_params;
+        QueryParameter* m_param;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOQUERYPARAMETER_H
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOQueryParameterCollection.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOQueryParameterCollection.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOQueryParameterCollection.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,84 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOQueryParameterCollection.h"
+#include "IOQueryParameter.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, Parameters);
+ELEM_MAP_ENTRY(2, Parameter);
+
+IOQueryParameterCollection::IOQueryParameterCollection(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_queryParameters = NULL;
+}
+
+IOQueryParameterCollection::IOQueryParameterCollection(QueryParameterCollection* queryParameters, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_queryParameters = queryParameters;
+}
+
+IOQueryParameterCollection::~IOQueryParameterCollection()
+{ }
+
+void IOQueryParameterCollection::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eParameters:
+        this->m_startElemName = name;
+        break;
+
+    case eParameter:
+        {
+            IOQueryParameter* IO = new IOQueryParameter(this->m_queryParameters, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOQueryParameterCollection::ElementChars(const wchar_t* ch)
+{ }
+
+void IOQueryParameterCollection::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_queryParameters->SetUnknownXml(this->m_unknownXml);
+
+        this->m_queryParameters = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+void IOQueryParameterCollection::Write(MdfStream& fd, QueryParameterCollection* queryParameters, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOQueryParameterCollection.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOQueryParameterCollection.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOQueryParameterCollection.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,47 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOQUERYPARAMETERCOLLECTION_H
+#define _IOQUERYPARAMETERCOLLECTION_H
+
+#include "SAX2ElementHandler.h"
+#include "QueryParameter.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOQueryParameterCollection : public SAX2ElementHandler
+{
+    public:
+        IOQueryParameterCollection(Version& version);
+        IOQueryParameterCollection(QueryParameterCollection* queryParameters, Version& version);
+        virtual ~IOQueryParameterCollection();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, QueryParameterCollection* queryParameters, Version* version, MgTab& tab);
+
+    private:
+        QueryParameterCollection* m_queryParameters;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOQUERYPARAMETERCOLLECTION_H
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOSQLQueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOSQLQueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOSQLQueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,129 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOSQLQueryDefinition.h"
+#include "IOGeometryInfo.h"
+#include "IOQueryParameter.h"
+#include "Common/IOStringObjectCollection.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, AggregateQueryDefinition);
+ELEM_MAP_ENTRY(2, ResourceId);
+ELEM_MAP_ENTRY(3, GeometryInfo);
+ELEM_MAP_ENTRY(4, IdentityProperties);
+ELEM_MAP_ENTRY(5, Parameters);
+ELEM_MAP_ENTRY(6, SQL);
+ELEM_MAP_ENTRY(7, ExtendedData1);
+
+IOSQLQueryDefinition::IOSQLQueryDefinition(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_query = NULL;
+}
+
+IOSQLQueryDefinition::IOSQLQueryDefinition(SQLQueryDefinition* query, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_query = query;
+}
+
+IOSQLQueryDefinition::~IOSQLQueryDefinition()
+{ }
+
+void IOSQLQueryDefinition::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eAggregateQueryDefinition:
+        this->m_startElemName = name;
+        break;
+
+    case eGeometryInfo:
+        {
+            GeometryInfo* geom = this->m_query->GetGeometryInfo();
+            IOGeometryInfo* IO = new IOGeometryInfo(geom, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eIdentityProperties:
+        {
+            StringObjectCollection* props = this->m_query->GetIdentityProperties();
+            IOStringObjectCollection* IO = new IOStringObjectCollection(props, this->m_version, "IdentityProperties", "Property"); //NOXLATE
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eParameters:
+        {
+            QueryParameterCollection* queryParams = this->m_query->GetParameters();
+            IOQueryParameter* IO = new IOQueryParameter(queryParams, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eExtendedData1:
+        this->m_procExtData = true;
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOSQLQueryDefinition::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eResourceId:
+        this->m_query->SetResourceID(ch);
+        break;
+
+    case eSQL:
+        this->m_query->SetSQL(ch);
+        break;
+    }
+}
+
+void IOSQLQueryDefinition::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_query->SetUnknownXml(this->m_unknownXml);
+
+        this->m_query = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+    else if (eExtendedData1 == _ElementIdFromName(name))
+    {
+        this->m_procExtData = false;
+    }
+}
+
+void IOSQLQueryDefinition::Write(MdfStream& fd, SQLQueryDefinition* query, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOSQLQueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOSQLQueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOSQLQueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,47 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOSQLQUERYDEFINITION_H
+#define _IOSQLQUERYDEFINITION_H
+
+#include "SAX2ElementHandler.h"
+#include "SQLQueryDefinition.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOSQLQueryDefinition : public SAX2ElementHandler
+{
+    public:
+        IOSQLQueryDefinition(Version& version);
+        IOSQLQueryDefinition(SQLQueryDefinition* query, Version& version);
+        virtual ~IOSQLQueryDefinition();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, SQLQueryDefinition* query, Version* version, MgTab& tab);
+
+    private:
+        SQLQueryDefinition* m_query;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOSQLQUERYDEFINITION_H
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOSpatialContext.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOSpatialContext.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOSpatialContext.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,130 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOGeometryInfo.h"
+#include "IOSpatialContext.h"
+#include "IOSpatialContextExtent.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, SpatialContext);
+ELEM_MAP_ENTRY(2, Name);
+ELEM_MAP_ENTRY(3, Description);
+ELEM_MAP_ENTRY(4, CoordinateSystemName);
+ELEM_MAP_ENTRY(5, CoordinateSystemWkt);
+ELEM_MAP_ENTRY(6, ExtentType);
+ELEM_MAP_ENTRY(7, Extent);
+ELEM_MAP_ENTRY(8, XYTolerance);
+ELEM_MAP_ENTRY(9, ZTolerance);
+ELEM_MAP_ENTRY(10, ExtendedData1);
+
+IOSpatialContext::IOSpatialContext(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_geom = NULL;
+}
+
+IOSpatialContext::IOSpatialContext(GeometryInfo* geom, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_geom = geom;
+}
+
+IOSpatialContext::~IOSpatialContext()
+{ }
+
+void IOSpatialContext::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eSpatialContext:
+        this->m_startElemName = name;
+        break;
+
+    case eExtent:
+        {
+            IOSpatialContextExtent* IO = new IOSpatialContextExtent(this->m_geom, this->m_version);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOSpatialContext::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eName:
+        this->m_geom->SetSpatialContextName(ch);
+        break;
+
+    case eDescription:
+        this->m_geom->SetSpatialContextDescription(ch);
+        break;
+
+    case eCoordinateSystemName:
+        this->m_geom->SetCoordinateSystemName(ch);
+        break;
+
+    case eCoordinateSystemWkt:
+        this->m_geom->SetCoordinateSystemWkt(ch);
+        break;
+
+    case eExtentType:
+        if (::wcscmp(ch, L"Static") == 0) // NOXLATE
+            this->m_geom->SetSpatialContextExtentType(GeometryInfo::Static);
+        else if (::wcscmp(ch, L"Dynamic") == 0) // NOXLATE
+            this->m_geom->SetSpatialContextExtentType(GeometryInfo::Dynamic);
+
+    case eXYTolerance:
+        this->m_geom->SetSpatialContextXYTolerance(wstrToDouble(ch));
+        break;
+
+    case eZTolerance:
+        this->m_geom->SetSpatialContextZTolerance(wstrToDouble(ch));
+        break;
+    }
+}
+
+void IOSpatialContext::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_geom->SetUnknownXml(this->m_unknownXml);
+
+        this->m_geom = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+    else if (eExtendedData1 == _ElementIdFromName(name))
+    {
+        this->m_procExtData = false;
+    }
+}
+
+void IOSpatialContext::Write(MdfStream& fd, GeometryInfo* geom, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOSpatialContext.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOSpatialContext.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOSpatialContext.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,47 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOSPATIALCONTEXT_H
+#define _IOSPATIALCONTEXT_H
+
+#include "SAX2ElementHandler.h"
+#include "GeometryInfo.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOSpatialContext : public SAX2ElementHandler
+{
+    public:
+        IOSpatialContext(Version& version);
+        IOSpatialContext(GeometryInfo* geom, Version& version);
+        virtual ~IOSpatialContext();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, GeometryInfo* geom, Version* version, MgTab& tab);
+
+    private:
+        GeometryInfo* m_geom;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOSPATIALCONTEXT_H
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOSpatialContextCoordinate.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOSpatialContextCoordinate.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOSpatialContextCoordinate.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,108 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOSpatialContextCoordinate.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, LowerLeftCoordinate);
+ELEM_MAP_ENTRY(2, UpperRightCoordinate);
+ELEM_MAP_ENTRY(3, X);
+ELEM_MAP_ENTRY(4, Y);
+ELEM_MAP_ENTRY(5, Z);
+ELEM_MAP_ENTRY(6, M);
+
+IOSpatialContextCoordinate::IOSpatialContextCoordinate(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_coord = NULL;
+    this->m_bLowerLeft = true;
+}
+
+IOSpatialContextCoordinate::IOSpatialContextCoordinate(SpatialContextCoordinate* coord, Version& version, bool bLowerLeft) : SAX2ElementHandler(version)
+{
+    this->m_coord = coord;
+    this->m_bLowerLeft = bLowerLeft;
+}
+
+IOSpatialContextCoordinate::~IOSpatialContextCoordinate()
+{ }
+
+void IOSpatialContextCoordinate::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eLowerLeftCoordinate:
+        {
+            if (this->m_bLowerLeft)
+                this->m_startElemName = name;
+        }
+        break;
+
+    case eUpperRightCoordinate:
+        {
+            if (!this->m_bLowerLeft)
+                this->m_startElemName = name;
+        }
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOSpatialContextCoordinate::ElementChars(const wchar_t* ch)
+{
+    switch (this->m_currElemId)
+    {
+    case eX:
+        this->m_coord->SetX(wstrToDouble(ch));
+        break;
+
+    case eY:
+        this->m_coord->SetY(wstrToDouble(ch));
+        break;
+
+    case eZ:
+        this->m_coord->SetZ(wstrToDouble(ch));
+        break;
+
+    case eM:
+        this->m_coord->SetM(wstrToDouble(ch));
+        break;
+    }
+}
+
+void IOSpatialContextCoordinate::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_coord = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+void IOSpatialContextCoordinate::Write(MdfStream& fd, SpatialContextCoordinate* coord, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOSpatialContextCoordinate.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOSpatialContextCoordinate.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOSpatialContextCoordinate.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOSPATIALCONTEXTCOORDINATE_H
+#define _IOSPATIALCONTEXTCOORDINATE_H
+
+#include "SAX2ElementHandler.h"
+#include "GeometryInfo.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOSpatialContextCoordinate : public SAX2ElementHandler
+{
+    public:
+        IOSpatialContextCoordinate(Version& version);
+        IOSpatialContextCoordinate(SpatialContextCoordinate* coord, Version& version, bool bLowerLeft);
+        virtual ~IOSpatialContextCoordinate();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, SpatialContextCoordinate* coord, Version* version, MgTab& tab);
+
+    private:
+        SpatialContextCoordinate* m_coord;
+        bool m_bLowerLeft; //false - upper right
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOSPATIALCONTEXTCOORDINATE_H
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOSpatialContextExtent.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOSpatialContextExtent.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOSpatialContextExtent.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,97 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#include "stdafx.h"
+#include "IOSpatialContextExtent.h"
+#include "IOSpatialContextCoordinate.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+using namespace MDFPARSER_NAMESPACE;
+
+CREATE_ELEMENT_MAP;
+ELEM_MAP_ENTRY(1, Extent);
+ELEM_MAP_ENTRY(2, LowerLeftCoordinate);
+ELEM_MAP_ENTRY(3, UpperRightCoordinate);
+
+IOSpatialContextExtent::IOSpatialContextExtent(Version& version) : SAX2ElementHandler(version)
+{
+    this->m_geom = NULL;
+}
+
+IOSpatialContextExtent::IOSpatialContextExtent(GeometryInfo* geom, Version& version) : SAX2ElementHandler(version)
+{
+    this->m_geom = geom;
+}
+
+IOSpatialContextExtent::~IOSpatialContextExtent()
+{ }
+
+void IOSpatialContextExtent::StartElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    this->m_currElemName = name;
+    this->m_currElemId = _ElementIdFromName(name);
+
+    switch (this->m_currElemId)
+    {
+    case eExtent:
+        this->m_startElemName = name;
+        break;
+
+    case eLowerLeftCoordinate:
+        {
+            SpatialContextCoordinate* coord = new SpatialContextCoordinate();
+            this->m_geom->AdoptSpatialContextLowerLeftCoordinate(coord);
+            IOSpatialContextCoordinate* IO = new IOSpatialContextCoordinate(coord, this->m_version, true);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eUpperRightCoordinate:
+        {
+            SpatialContextCoordinate* coord = new SpatialContextCoordinate();
+            this->m_geom->AdoptSpatialContextUpperRightCoordinate(coord);
+            IOSpatialContextCoordinate* IO = new IOSpatialContextCoordinate(coord, this->m_version, false);
+            handlerStack->push(IO);
+            IO->StartElement(name, handlerStack);
+        }
+        break;
+
+    case eUnknown:
+        ParseUnknownXml(name, handlerStack);
+        break;
+    }
+}
+
+void IOSpatialContextExtent::ElementChars(const wchar_t* ch)
+{ }
+
+void IOSpatialContextExtent::EndElement(const wchar_t* name, HandlerStack* handlerStack)
+{
+    if (this->m_startElemName == name)
+    {
+        this->m_geom->SetUnknownXml(this->m_unknownXml);
+
+        this->m_geom = NULL;
+        this->m_startElemName = L"";
+        handlerStack->pop();
+        delete this;
+    }
+}
+
+void IOSpatialContextExtent::Write(MdfStream& fd, GeometryInfo* geom, Version* version, MgTab& tab)
+{ }
\ No newline at end of file

Added: sandbox/jng/querydef/Common/MdfParser/IOSpatialContextExtent.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/IOSpatialContextExtent.h	                        (rev 0)
+++ sandbox/jng/querydef/Common/MdfParser/IOSpatialContextExtent.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,47 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef _IOSPATIALCONTEXTEXTENT_H
+#define _IOSPATIALCONTEXTEXTENT_H
+
+#include "SAX2ElementHandler.h"
+#include "GeometryInfo.h"
+#include "Version.h"
+
+using namespace XERCES_CPP_NAMESPACE;
+using namespace MDFMODEL_NAMESPACE;
+
+BEGIN_NAMESPACE_MDFPARSER
+
+class IOSpatialContextExtent : public SAX2ElementHandler
+{
+    public:
+        IOSpatialContextExtent(Version& version);
+        IOSpatialContextExtent(GeometryInfo* geom, Version& version);
+        virtual ~IOSpatialContextExtent();
+
+        virtual void StartElement(const wchar_t* name, HandlerStack* handlerStack);
+        virtual void ElementChars(const wchar_t* ch);
+        virtual void EndElement(const wchar_t* name, HandlerStack* handlerStack);
+
+        static void Write(MdfStream& fd, GeometryInfo* geom, Version* version, MgTab& tab);
+
+    private:
+        GeometryInfo* m_geom;
+};
+
+END_NAMESPACE_MDFPARSER
+#endif // _IOSPATIALCONTEXTEXTENT_H
\ No newline at end of file

Modified: sandbox/jng/querydef/Common/MdfParser/MdfParser.vcxproj
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/MdfParser.vcxproj	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MdfParser/MdfParser.vcxproj	2013-04-30 15:21:47 UTC (rev 7465)
@@ -195,6 +195,15 @@
     <ClCompile Include="Common\IOSize2D.cpp" />
     <ClCompile Include="Common\IOStringObjectCollection.cpp" />
     <ClCompile Include="Common\IOVector3D.cpp" />
+    <ClCompile Include="IOAggregateQueryDefinition.cpp" />
+    <ClCompile Include="IOFeatureQueryDefinition.cpp" />
+    <ClCompile Include="IOGeometryInfo.cpp" />
+    <ClCompile Include="IOQueryParameter.cpp" />
+    <ClCompile Include="IOQueryParameterCollection.cpp" />
+    <ClCompile Include="IOSpatialContext.cpp" />
+    <ClCompile Include="IOSpatialContextCoordinate.cpp" />
+    <ClCompile Include="IOSpatialContextExtent.cpp" />
+    <ClCompile Include="IOSQLQueryDefinition.cpp" />
     <ClCompile Include="IOURLData.cpp" />
     <ClCompile Include="IOProfileRenderLabelsResult.cpp" />
     <ClCompile Include="IOProfileRenderLayerResult.cpp" />
@@ -307,6 +316,15 @@
     <ClInclude Include="Common\IOSize2D.h" />
     <ClInclude Include="Common\IOStringObjectCollection.h" />
     <ClInclude Include="Common\IOVector3D.h" />
+    <ClInclude Include="IOAggregateQueryDefinition.h" />
+    <ClInclude Include="IOFeatureQueryDefinition.h" />
+    <ClInclude Include="IOGeometryInfo.h" />
+    <ClInclude Include="IOQueryParameter.h" />
+    <ClInclude Include="IOQueryParameterCollection.h" />
+    <ClInclude Include="IOSpatialContext.h" />
+    <ClInclude Include="IOSpatialContextCoordinate.h" />
+    <ClInclude Include="IOSpatialContextExtent.h" />
+    <ClInclude Include="IOSQLQueryDefinition.h" />
     <ClInclude Include="IOURLData.h" />
     <ClInclude Include="IOProfileRenderLabelsResult.h" />
     <ClInclude Include="IOProfileRenderLayerResult.h" />

Modified: sandbox/jng/querydef/Common/MdfParser/MdfParser.vcxproj.filters
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/MdfParser.vcxproj.filters	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MdfParser/MdfParser.vcxproj.filters	2013-04-30 15:21:47 UTC (rev 7465)
@@ -10,6 +10,9 @@
     <Filter Include="ProfileResult">
       <UniqueIdentifier>{ba1fc980-0d34-4134-8059-68b42135be47}</UniqueIdentifier>
     </Filter>
+    <Filter Include="QueryDefinition">
+      <UniqueIdentifier>{b4516074-e7eb-4b09-8e8a-998deb9b0ded}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Common\IOColor.cpp">
@@ -172,6 +175,33 @@
     <ClCompile Include="IOProfileResult.cpp">
       <Filter>ProfileResult</Filter>
     </ClCompile>
+    <ClCompile Include="IOFeatureQueryDefinition.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="IOAggregateQueryDefinition.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="IOSQLQueryDefinition.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="IOGeometryInfo.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="IOQueryParameter.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="IOSpatialContext.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="IOSpatialContextExtent.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="IOSpatialContextCoordinate.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
+    <ClCompile Include="IOQueryParameterCollection.cpp">
+      <Filter>QueryDefinition</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Common\IOColor.h">
@@ -334,6 +364,33 @@
     <ClInclude Include="IOProfileResult.h">
       <Filter>ProfileResult</Filter>
     </ClInclude>
+    <ClInclude Include="IOFeatureQueryDefinition.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="IOAggregateQueryDefinition.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="IOSQLQueryDefinition.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="IOGeometryInfo.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="IOQueryParameter.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="IOSpatialContext.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="IOSpatialContextExtent.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="IOSpatialContextCoordinate.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
+    <ClInclude Include="IOQueryParameterCollection.h">
+      <Filter>QueryDefinition</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="MdfParser.rc" />

Modified: sandbox/jng/querydef/Common/MdfParser/SAX2Parser.cpp
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/SAX2Parser.cpp	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MdfParser/SAX2Parser.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -29,6 +29,9 @@
 #include "PrintLayout/IOMapViewportDefinition.h"
 #include "IOWatermarkDefinition.h"
 #include "IOProfileResult.h"
+#include "IOFeatureQueryDefinition.h"
+#include "IOAggregateQueryDefinition.h"
+#include "IOSQLQueryDefinition.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -212,7 +215,51 @@
     return NULL;
 }
 
+// Returns a reference to the parser's query definition
+// After this call the parser no longer owns the object.
+QueryDefinition* SAX2Parser::DetachQueryDefinition()
+{
+    if (m_featureQuery)
+        return DetachFeatureQueryDefinition();
 
+    if (m_aggregateQuery)
+        return DetachAggregateQueryDefinition();
+
+    if (m_sqlQuery)
+        return DetachSQLQueryDefinition();
+
+    return NULL;
+}
+
+// Returns a reference to the parser's vector layer definition
+// After this call the parser no longer owns the object.
+FeatureQueryDefinition* SAX2Parser::DetachFeatureQueryDefinition()
+{
+    FeatureQueryDefinition* ret = m_featureQuery;
+    m_featureQuery = NULL;
+    return ret;
+}
+
+
+// Returns a reference to the parser's drawing layer definition
+// After this call the parser no longer owns the object.
+AggregateQueryDefinition* SAX2Parser::DetachAggregateQueryDefinition()
+{
+    AggregateQueryDefinition* ret = m_aggregateQuery;
+    m_aggregateQuery = NULL;
+    return ret;
+}
+
+
+// Returns a reference to the parser's grid layer definition
+// After this call the parser no longer owns the object.
+SQLQueryDefinition* SAX2Parser::DetachSQLQueryDefinition()
+{
+    SQLQueryDefinition* ret = m_sqlQuery;
+    m_sqlQuery = NULL;
+    return ret;
+}
+
 // Returns a reference to the parser's simple symbol definition
 // After this call the parser no longer owns the object.
 SimpleSymbolDefinition* SAX2Parser::DetachSimpleSymbolDefinition()
@@ -581,6 +628,11 @@
             // just set the version
             SetLayerDefinitionVersion(attributes);
         }
+        else if (str == L"QueryDefinition") // NOXLATE
+        {
+            // just set the version
+            SetQueryDefinitionVersion(attributes);
+        }
         else if (str == L"VectorLayerDefinition") // NOXLATE
         {
             _ASSERT(m_vLayer == NULL);  // otherwise we leak
@@ -605,6 +657,30 @@
             m_handlerStack->push(IO);
             IO->StartElement(str.c_str(), m_handlerStack);
         }
+        else if (str == L"FeatureQueryDefinition") // NOXLATE
+        {
+            _ASSERT(m_featureQuery == NULL);  // otherwise we leak
+            m_featureQuery = new FeatureQueryDefinition(L"", L"");
+            IOFeatureQueryDefinition* IO = new IOFeatureQueryDefinition(m_featureQuery, m_version);
+            m_handlerStack->push(IO);
+            IO->StartElement(str.c_str(), m_handlerStack);
+        }
+        else if (str == L"AggregateQueryDefinition") // NOXLATE
+        {
+            _ASSERT(m_aggregateQuery == NULL);  // otherwise we leak
+            m_aggregateQuery = new AggregateQueryDefinition(L"", L"");
+            IOAggregateQueryDefinition* IO = new IOAggregateQueryDefinition(m_aggregateQuery, m_version);
+            m_handlerStack->push(IO);
+            IO->StartElement(str.c_str(), m_handlerStack);
+        }
+        else if (str == L"SQLQueryDefinition") // NOXLATE
+        {
+            _ASSERT(m_sqlQuery == NULL);  // otherwise we leak
+            m_sqlQuery = new SQLQueryDefinition(L"");
+            IOSQLQueryDefinition* IO = new IOSQLQueryDefinition(m_sqlQuery, m_version);
+            m_handlerStack->push(IO);
+            IO->StartElement(str.c_str(), m_handlerStack);
+        }
         else if (str == L"SimpleSymbolDefinition") // NOXLATE
         {
             // set the version
@@ -889,7 +965,31 @@
     }
 }
 
+void SAX2Parser::SetQueryDefinitionVersion(const Attributes& attributes)
+{
+    // Although right now we only have 2.6.0 here, this function is still
+    // needed for future expansion.
 
+    // check for a version attribute
+    int index = attributes.getIndex(W2X(L"version"));
+    const XMLCh* verValue = (index >= 0)? attributes.getValue(index) : NULL;
+
+    // according to the schema query definition elements require a version
+    // attribute, but users may generate XML which is missing this attribute
+    if (verValue)
+    {
+        std::wstring version = X2W(verValue);
+
+        if (_wcsicmp(version.c_str(), L"2.6.0") == 0)
+            m_version = MdfModel::Version(2, 6, 0);
+    }
+    else
+    {
+        // assume the latest version if the attribute is missing
+        m_version = MdfModel::Version(2, 6, 0);
+    }
+}
+
 MapDefinition* SAX2Parser::CreateClone(MapDefinition* map)
 {
     _ASSERT(NULL != map);

Modified: sandbox/jng/querydef/Common/MdfParser/SAX2Parser.h
===================================================================
--- sandbox/jng/querydef/Common/MdfParser/SAX2Parser.h	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/MdfParser/SAX2Parser.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -29,6 +29,9 @@
 #include "PrintLayout/MapViewportDefinition.h"
 #include "WatermarkDefinition.h"
 #include "ProfileResult.h"
+#include "FeatureQueryDefinition.h"
+#include "AggregateQueryDefinition.h"
+#include "SQLQueryDefinition.h"
 
 // disable C4244 of XSerializeEngine about __w64 int assigned to unsigned long
 // disable C4267 of XmlScanner about size_t assigned to unsigned int
@@ -95,6 +98,7 @@
         std::string SerializeToXML(PrintLayoutElementDefinition* printLayoutElem, MdfModel::Version* version);
         std::string SerializeToXML(WatermarkDefinition* watermark, MdfModel::Version* version);
         std::string SerializeToXML(ProfileResult* profileResult, MdfModel::Version* version);
+        std::string SerializeToXML(QueryDefinition* query, MdfModel::Version* version);
 
         // Detaches the most recently parsed object from the parser.
         // The calling method is then responsible for disposing the object,
@@ -112,6 +116,10 @@
         MapViewportDefinition* DetachMapViewportDefinition();
         WatermarkDefinition* DetachWatermarkDefinition();
         ProfileResult* DetachProfileResult();
+        QueryDefinition* DetachQueryDefinition();
+        FeatureQueryDefinition* DetachFeatureQueryDefinition();
+        AggregateQueryDefinition* DetachAggregateQueryDefinition();
+        SQLQueryDefinition* DetachSQLQueryDefinition();
 
         // Creates a clone of the given map/layer/symbol/print layout/print layout element definition.
         // The object is serialized and parsed into a new object, which is returned.
@@ -122,6 +130,7 @@
         static PrintLayoutElementDefinition* CreateClone(PrintLayoutElementDefinition* printLayoutElem);
         static WatermarkDefinition* CreateClone(WatermarkDefinition* watermark);
         static ProfileResult* CreateClone(ProfileResult* profileResult);
+        static QueryDefinition* CreateClone(QueryDefinition* query);
 
         // Success State
         bool GetSucceeded() const;
@@ -162,6 +171,7 @@
         void SetPrintLayoutElementDefinitionVersion(const Attributes& attributes);
         void SetWatermarkDefinitionVersion(const Attributes& attributes);
         void SetProfileResultVersion(const Attributes& attributes);
+        void SetQueryDefinitionVersion(const Attributes& attributes);
 
     protected:
         // The objects to be generated by the parser.
@@ -175,6 +185,9 @@
         MapViewportDefinition* m_mapViewport;
         WatermarkDefinition* m_watermark;
         ProfileResult* m_profileResult;
+        FeatureQueryDefinition* m_featureQuery;
+        AggregateQueryDefinition* m_aggregateQuery;
+        SQLQueryDefinition* m_sqlQuery;
 
         // Succeeded is true if the parse has succeeded. As of now,
         // there are very loose constraints on this boolean.

Modified: sandbox/jng/querydef/Common/PlatformBase/Services/FeatureDefs.h
===================================================================
--- sandbox/jng/querydef/Common/PlatformBase/Services/FeatureDefs.h	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/PlatformBase/Services/FeatureDefs.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -77,6 +77,7 @@
     static const int AddSavePoint_Id                      = 0x1111ED2E;
     static const int RollbackSavePoint_Id                 = 0x1111ED2F;
     static const int ReleaseSavePoint_Id                  = 0x1111ED30;
+    static const int ExecuteQueryDefinition_Id            = 0x1111ED31;
 };
 /// \endcond
 

Modified: sandbox/jng/querydef/Common/PlatformBase/Services/FeatureService.h
===================================================================
--- sandbox/jng/querydef/Common/PlatformBase/Services/FeatureService.h	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/PlatformBase/Services/FeatureService.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -781,6 +781,66 @@
                                             MgFeatureQueryOptions* options,
                                             CREFSTRING coordinateSystem) = 0;
 
+    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+    /// a MgFeatureReader containing the query results
+    ///
+    /// \remarks
+    /// Any parameters that are defined in the Query Definition will assume default values when calling this overload.
+    /// Also be sure to Close() the MgFeatureReader object returned by this method.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource (MgResourceIdentifier)
+    /// A resource identifier for the Query Definition
+    ///
+    /// \return
+    /// Returns an MgFeatureReader containing the results of the executed query
+    ///
+    virtual MgFeatureReader* ExecuteQueryDefinition(MgResourceIdentifier* resource) = 0;
+
+    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+    /// a MgFeatureReader containing the query results
+    ///
+    /// \remarks
+    /// Any parameters that are defined in the Query Definition that are not specified in the parameter collection passed in 
+    /// will assume default values when calling this overload.
+    /// Also be sure to Close() the MgFeatureReader object returned by this method.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource (MgResourceIdentifier)
+    /// A resource identifier for the Query Definition
+    ///
+    /// \param parameters (MgPropertyCollection)
+    /// A collection of parameters to pass into this query
+    ///
+    /// \return
+    /// Returns an MgFeatureReader containing the results of the executed query
+    ///
+    virtual MgFeatureReader* ExecuteQueryDefinition(MgResourceIdentifier* resource, MgPropertyCollection* parameters) = 0;
+
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     /// \brief
     /// Selects groups of features from a feature source and applies

Modified: sandbox/jng/querydef/Common/PlatformBase/Services/ResourceDefs.cpp
===================================================================
--- sandbox/jng/querydef/Common/PlatformBase/Services/ResourceDefs.cpp	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/PlatformBase/Services/ResourceDefs.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -46,6 +46,7 @@
 const STRING MgResourceType::Folder                 = L"Folder";
 const STRING MgResourceType::LoadProcedure          = L"LoadProcedure";
 const STRING MgResourceType::PrintLayout            = L"PrintLayout";
+const STRING MgResourceType::QueryDefinition        = L"QueryDefinition";
 const STRING MgResourceType::Selection              = L"Selection";
 const STRING MgResourceType::SymbolDefinition       = L"SymbolDefinition";
 const STRING MgResourceType::SymbolLibrary          = L"SymbolLibrary";

Modified: sandbox/jng/querydef/Common/PlatformBase/Services/ResourceDefs.h
===================================================================
--- sandbox/jng/querydef/Common/PlatformBase/Services/ResourceDefs.h	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Common/PlatformBase/Services/ResourceDefs.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -199,6 +199,19 @@
 
     ////////////////////////////////////////////////////////////////
     /// \brief
+    /// This resource is a Query Definition.
+    ///
+    /// \note1
+    ///
+    /// \remarks
+    /// A query definition defines a Feature Source query
+    ///
+    /// \see \ref QueryDefinition_schema "QueryDefinition schema"
+    ///
+    static const STRING QueryDefinition;        ///\if INTERNAL value("QueryDefinition") \endif
+
+    ////////////////////////////////////////////////////////////////
+    /// \brief
     /// This resource is the runtime definition of a selection.
     ///
     /// \note1

Added: sandbox/jng/querydef/Common/Schema/QueryDefinition-2.6.0.xsd
===================================================================
--- sandbox/jng/querydef/Common/Schema/QueryDefinition-2.6.0.xsd	                        (rev 0)
+++ sandbox/jng/querydef/Common/Schema/QueryDefinition-2.6.0.xsd	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,325 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.6.0">
+  <xs:include schemaLocation="PlatformCommon-1.0.0.xsd"/>
+  <xs:element name="QueryDefinition">
+    <xs:annotation>
+      <xs:documentation>The specification of a Feature Source Query.</xs:documentation>
+    </xs:annotation>
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="QueryDefinitionType">
+          <xs:attribute name="version" type="xs:string" use="required" fixed="2.6.0"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:complexType name="QueryDefinitionType">
+    <xs:annotation>
+      <xs:documentation>Encapsulates the definition of a Feature Source Query</xs:documentation>
+    </xs:annotation>
+    <xs:choice>
+      <xs:element name="FeatureQueryDefinition" type="FeatureQueryDefinitionType">
+        <xs:annotation>
+          <xs:documentation>A standard FDO feature source query</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="AggregateQueryDefinition" type="AggregateQueryDefinitionType">
+        <xs:annotation>
+          <xs:documentation>A FDO aggregate query</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SQLQueryDefinition" type="SQLQueryDefinitionType">
+        <xs:annotation>
+          <xs:documentation>A SQL query executed through FDO</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:choice>
+  </xs:complexType>
+  <xs:complexType name="BaseQueryDefinitionType">
+    <xs:annotation>
+      <xs:documentation>Specifies common properties for all query types</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="ResourceId" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Link to the feature source. Provider capabilities should determine what optional elements in the rest of this schema are applicable</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="GeometryInfo" type="GeometryInfoType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>If specified, declares information about the designated geometry for purposes of rendering/stylization and spatial contexts</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="IdentityProperties" type="PropertyCollectionType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>If specified, declares which properties will be designated as geometries</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Parameters" type="QueryParameterCollectionType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>If specified, declares information about the parameters that can be passed into the query when executed. Parameters can be referenced from either the Filter element of a standard/aggregate query or a SQL query</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="BaseSelectQueryDefintionType">
+    <xs:annotation>
+      <xs:documentation>Specifies common properties for standard select and aggregate queries</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="BaseQueryDefinitionType">
+        <xs:sequence>
+          <xs:element name="FeatureClass" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>Specifies the feature class to query from</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Filter" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies the FDO filter for this query</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Properties" type="PropertyCollectionType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies the list of properties to include in the query. If this element is not specified, all properties are included</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ComputedProperties" type="ComputedPropertyCollectionType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies the list of computed properties to include in the query.</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="OrderBy" type="PropertyCollectionType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies the list of properties to order the select query by. The underlying provider must support select ordering</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="Ordering" type="SelectOrderingType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies the ordering direction</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="FeatureQueryDefinitionType">
+    <xs:annotation>
+      <xs:documentation>Specifies parameters for a standard Feature Source Query</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="BaseSelectQueryDefintionType">
+        <xs:sequence>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="AggregateQueryDefinitionType">
+    <xs:annotation>
+      <xs:documentation>Specifies parameters for an Aggregate Query</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="BaseSelectQueryDefintionType">
+        <xs:sequence>
+          <xs:element name="GroupBy" type="PropertyCollectionType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies the list of properties to group the aggregate query by</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="GroupFilter" type="xs:string" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>Specifies the grouping filter for the aggregate query</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="SQLQueryDefinitionType">
+    <xs:annotation>
+      <xs:documentation>Specifies parameters for a SQL query</xs:documentation>
+    </xs:annotation>
+    <xs:complexContent>
+      <xs:extension base="BaseQueryDefinitionType">
+        <xs:sequence>
+          <xs:element name="SQL" type="xs:string">
+            <xs:annotation>
+              <xs:documentation>Specifies the SQL SELECT query string. This string may contain parameter references. The SQL is a dialect specific to the underlying provider</xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+  <xs:complexType name="PropertyCollectionType">
+    <xs:annotation>
+      <xs:documentation>Specifies a collection of class properties</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Property" type="xs:string" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>Specifies the FDO class property name</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="ComputedPropertyCollectionType">
+    <xs:annotation>
+      <xs:documentation>Specifies a collection of computed properties</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="ComputedProperty" type="ComputedPropertyType" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>Specifies the computed property</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="ComputedPropertyType">
+    <xs:annotation>
+      <xs:documentation>Specifies a computed property</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Specifies the alias for this computed property</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Expression" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>Specifies the FDO expression for this computed property</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="GeometryInfoType">
+    <xs:annotation>
+      <xs:documentation>Specifies geometric and spatial context information for the query</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Geometry" type="xs:string" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>Specifies the designated geometry property or column.</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="GeometryTypes" type="xs:integer">
+        <xs:annotation>
+          <xs:documentation>A bitmask value representing the applicable geometry types</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="SpatialContext">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="Name" type="xs:string"/>
+            <xs:element name="Description" type="xs:string"/>
+            <xs:element name="CoordinateSystemName" type="xs:string"/>
+            <xs:element name="CoordinateSystemWkt" type="xs:string"/>
+            <xs:element name="ExtentType">
+              <xs:simpleType>
+                <xs:restriction base="xs:string">
+                  <xs:enumeration value="Static"/>
+                  <xs:enumeration value="Dynamic"/>
+                </xs:restriction>
+              </xs:simpleType>
+            </xs:element>
+            <xs:element name="Extent">
+              <xs:annotation>
+                <xs:documentation>This would return AWKT representing extents e.g. polygon, polyline or circle etc.</xs:documentation>
+              </xs:annotation>
+              <xs:complexType>
+                <xs:sequence>
+                  <xs:element name="LowerLeftCoordinate">
+                    <xs:complexType>
+                      <xs:sequence>
+                        <xs:element name="X" type="xs:string"/>
+                        <xs:element name="Y" type="xs:string"/>
+                        <xs:element name="Z" type="xs:string" minOccurs="0"/>
+                        <xs:element name="M" type="xs:string" minOccurs="0"/>
+                      </xs:sequence>
+                    </xs:complexType>
+                  </xs:element>
+                  <xs:element name="UpperRightCoordinate">
+                    <xs:complexType>
+                      <xs:sequence>
+                        <xs:element name="X" type="xs:string"/>
+                        <xs:element name="Y" type="xs:string"/>
+                        <xs:element name="Z" type="xs:string" minOccurs="0"/>
+                        <xs:element name="M" type="xs:string" minOccurs="0"/>
+                      </xs:sequence>
+                    </xs:complexType>
+                  </xs:element>
+                </xs:sequence>
+              </xs:complexType>
+            </xs:element>
+            <xs:element name="XYTolerance" type="xs:double"/>
+            <xs:element name="ZTolerance" type="xs:double"/>
+            <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="QueryParameterCollectionType">
+    <xs:annotation>
+      <xs:documentation>Specifies a collection of query parameters</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Parameter" type="QueryParameterType" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>Collection of query parameters</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="QueryParameterType">
+    <xs:annotation>
+      <xs:documentation>Specifies a query parameter</xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="Name" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The name of the query parameter</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="Type" type="QueryParameterDataType">
+        <xs:annotation>
+          <xs:documentation>The data type of the query parameter</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="DefaultValue" type="xs:string">
+        <xs:annotation>
+          <xs:documentation>The default value for the query parameter</xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:simpleType name="QueryParameterDataType">
+    <xs:annotation>
+      <xs:documentation>Specifies the data type of a query parameter</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Boolean"/>
+      <xs:enumeration value="Byte"/>
+      <xs:enumeration value="DateTime"/>
+      <xs:enumeration value="Double"/>
+      <xs:enumeration value="Int16"/>
+      <xs:enumeration value="Int32"/>
+      <xs:enumeration value="Int64"/>
+      <xs:enumeration value="Single"/>
+      <xs:enumeration value="String"/>
+      <xs:enumeration value="Geometry"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="SelectOrderingType">
+    <xs:annotation>
+      <xs:documentation>Specifies select ordering direction</xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="Ascending"/>
+      <xs:enumeration value="Descending"/>
+    </xs:restriction>
+  </xs:simpleType>
+</xs:schema>
\ No newline at end of file

Modified: sandbox/jng/querydef/Server/src/PostBuild/PostBuild.mak
===================================================================
--- sandbox/jng/querydef/Server/src/PostBuild/PostBuild.mak	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/PostBuild/PostBuild.mak	2013-04-30 15:21:47 UTC (rev 7465)
@@ -247,6 +247,17 @@
         ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource \
         ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite \
         ..\..\bin\UnitTestFiles\JoinTest.sqlite \
+        ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition \
         CopyFdoComponentsDebug \
         CopyFdoProvidersDebug \
         CopySchemaDebug \
@@ -504,6 +515,17 @@
         ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource \
         ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite \
         ..\..\bin\UnitTestFiles\JoinTest.sqlite \
+        ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition \
+        ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition \
         CopyFdoComponentsDebug64 \
         CopyFdoProvidersDebug64 \
         CopySchemaDebug64 \
@@ -1018,6 +1040,17 @@
           ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource \
           ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite \
           ..\..\bin\UnitTestFiles\JoinTest.sqlite \
+          ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition \
+          ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition \
           CopyFdoComponentsRelease64 \
           CopyFdoProvidersRelease64 \
           CopySchemaRelease64 \
@@ -1148,6 +1181,17 @@
     if EXIST ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource		del /F ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource
     if EXIST ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite         del /F ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite
     if EXIST ..\..\bin\UnitTestFiles\JoinTest.sqlite                del /F ..\..\bin\UnitTestFiles\JoinTest.FeatureSource
+    if EXIST ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition                  del /F ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition         del /F ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition                del /F ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition                  del /F ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition   del /F ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition                 del /F ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition                        del /F ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition                        del /F ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition
     del /F   ..\..\bin\debug\*.ilk
 
 
@@ -1273,6 +1317,17 @@
     if EXIST ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource		del /F ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource
     if EXIST ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite         del /F ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite
     if EXIST ..\..\bin\UnitTestFiles\JoinTest.sqlite                del /F ..\..\bin\UnitTestFiles\JoinTest.FeatureSource
+    if EXIST ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition                  del /F ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition         del /F ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition                del /F ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition                  del /F ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition   del /F ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition                 del /F ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition                        del /F ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition                        del /F ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition
     del /F   ..\..\bin\debug64\*.ilk
 
 
@@ -1394,10 +1449,21 @@
     if EXIST ..\..\bin\UnitTestFiles\UT_Annotation3.mdf             del /F ..\..\bin\UnitTestFiles\UT_Annotation3.mdf
     if EXIST ..\..\bin\UnitTestFiles\SavePointTest.sqlite           del /F ..\..\bin\UnitTestFiles\SavePointTest.sqlite
     if EXIST ..\..\bin\UnitTestFiles\SavePointTest.FeatureSource    del /F ..\..\bin\UnitTestFiles\SavePointTest.FeatureSource
-	if EXIST ..\..\bin\UnitTestFiles\UT_Parcels_SQLite_Join.FeatureSource    del /F ..\..\bin\UnitTestFiles\UT_Parcels_SQLite_Join.FeatureSource
-    if EXIST ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource		del /F ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource
+    if EXIST ..\..\bin\UnitTestFiles\UT_Parcels_SQLite_Join.FeatureSource    del /F ..\..\bin\UnitTestFiles\UT_Parcels_SQLite_Join.FeatureSource
+    if EXIST ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource       del /F ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource
     if EXIST ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite         del /F ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite
     if EXIST ..\..\bin\UnitTestFiles\JoinTest.sqlite                del /F ..\..\bin\UnitTestFiles\JoinTest.FeatureSource
+    if EXIST ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition                  del /F ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition         del /F ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition                del /F ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition                  del /F ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition   del /F ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition                 del /F ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition                        del /F ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition                        del /F ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition
 
 cleanrelease64:
     if EXIST ..\..\bin\release64\MgFoundation.dll              del /F ..\..\bin\release64\MgFoundation.dll
@@ -1518,11 +1584,21 @@
     if EXIST ..\..\bin\UnitTestFiles\SavePointTest.sqlite           del /F ..\..\bin\UnitTestFiles\SavePointTest.sqlite
     if EXIST ..\..\bin\UnitTestFiles\SavePointTest.FeatureSource    del /F ..\..\bin\UnitTestFiles\SavePointTest.FeatureSource
     if EXIST ..\..\bin\UnitTestFiles\UT_Parcels_SQLite_Join.FeatureSource    del /F ..\..\bin\UnitTestFiles\UT_Parcels_SQLite_Join.FeatureSource
-    if EXIST ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource		del /F ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource
+    if EXIST ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource       del /F ..\..\bin\UnitTestFiles\UT_FdoJoin.FeatureSource
     if EXIST ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite         del /F ..\..\bin\UnitTestFiles\ParcelsJoinTest.sqlite
     if EXIST ..\..\bin\UnitTestFiles\JoinTest.sqlite                del /F ..\..\bin\UnitTestFiles\JoinTest.FeatureSource
+    if EXIST ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition                  del /F ..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition         del /F ..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition                del /F ..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition                  del /F ..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition   del /F ..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition                 del /F ..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition                        del /F ..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition                        del /F ..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition
+    if EXIST ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition                    del /F ..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition
 
-
 "..\..\..\UnitTest\TestData\ResourceService\LibraryRepositoryContent.xml" :
 "..\..\..\UnitTest\TestData\ResourceService\SampleRepositoryHeader.xml" :
 "..\..\..\UnitTest\TestData\ResourceService\SampleRepositoryContent.xml" :
@@ -1969,4 +2045,48 @@
 
 ..\..\bin\UnitTestFiles\JoinTest.sqlite : "..\..\..\UnitTest\TestData\FeatureService\SQLite\JoinTest.sqlite"
     if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
-    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\JoinTest.sqlite" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\JoinTest.sqlite" ..\..\bin\UnitTestFiles\
\ No newline at end of file
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\JoinTest.sqlite" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\JoinTest.sqlite" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_AggregateCount.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_AggregateCount.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_AggregateCount.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_AggregateCount.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_AggregateSpatialExtents.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_AggregateSpatialExtents.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_AggregateSpatialExtents.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_AggregateSpatialExtents.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_BasicAllElements.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicAllElements.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicAllElements.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicAllElements.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_BasicBarebones.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicBarebones.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicBarebones.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicBarebones.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_BasicMinimal.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicMinimal.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicMinimal.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicMinimal.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_BasicWithExplicitPropertyList.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicWithExplicitPropertyList.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicWithExplicitPropertyList.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicWithExplicitPropertyList.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_BasicWithFilter.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicWithFilter.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicWithFilter.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_BasicWithFilter.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_SQLBasic.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLBasic.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLBasic.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLBasic.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_SQLWhere.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLWhere.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLWhere.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLWhere.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_SQLWhereJoin.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLWhereJoin.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLWhereJoin.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLWhereJoin.QueryDefinition" ..\..\bin\UnitTestFiles\
+
+..\..\bin\UnitTestFiles\UT_SQLAggregate.QueryDefinition : "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLAggregate.QueryDefinition"
+    if NOT EXIST ..\..\bin\UnitTestFiles\nul mkdir ..\..\bin\UnitTestFiles
+    if EXIST "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLAggregate.QueryDefinition" xcopy /r /d /y "..\..\..\UnitTest\TestData\FeatureService\SQLite\UT_SQLAggregate.QueryDefinition" ..\..\bin\UnitTestFiles\
\ No newline at end of file

Modified: sandbox/jng/querydef/Server/src/Services/Feature/FeatureOperationFactory.cpp
===================================================================
--- sandbox/jng/querydef/Server/src/Services/Feature/FeatureOperationFactory.cpp	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/Services/Feature/FeatureOperationFactory.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -61,6 +61,7 @@
 #include "OpCommitTransaction.h"
 #include "OpRollbackTransaction.h"
 #include "OpUpdateFeaturesWithTransaction.h"
+#include "OpExecuteQueryDefinition.h"
 
 ///////////////////////////////////////////////////////////////////////////////
 /// <summary>
@@ -648,6 +649,18 @@
         }
         break;
 
+    case MgFeatureServiceOpId::ExecuteQueryDefinition_Id:
+		switch (VERSION_NO_PHASE(operationVersion))
+        {
+        case VERSION_SUPPORTED(1,0):
+            handler.reset(new MgOpExecuteQueryDefinition());
+            break;
+        default:
+            throw new MgInvalidOperationVersionException(
+                L"MgFeatureOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+        break;
+
     default:
         throw new MgInvalidOperationException(
             L"MgFeatureOperationFactory.GetOperation", __LINE__, __WFILE__, NULL, L"", NULL);

Added: sandbox/jng/querydef/Server/src/Services/Feature/OpExecuteQueryDefinition.cpp
===================================================================
--- sandbox/jng/querydef/Server/src/Services/Feature/OpExecuteQueryDefinition.cpp	                        (rev 0)
+++ sandbox/jng/querydef/Server/src/Services/Feature/OpExecuteQueryDefinition.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,134 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "ServerFeatureServiceDefs.h"
+#include "OpExecuteQueryDefinition.h"
+#include "ServerFeatureService.h"
+#include "LogManager.h"
+
+
+///----------------------------------------------------------------------------
+/// <summary>
+/// Constructs the object.
+/// </summary>
+///----------------------------------------------------------------------------
+MgOpExecuteQueryDefinition::MgOpExecuteQueryDefinition()
+{
+}
+
+
+///----------------------------------------------------------------------------
+/// <summary>
+/// Destructs the object.
+/// </summary>
+///----------------------------------------------------------------------------
+MgOpExecuteQueryDefinition::~MgOpExecuteQueryDefinition()
+{
+}
+
+
+///----------------------------------------------------------------------------
+/// <summary>
+/// Executes the operation.
+/// </summary>
+///
+/// <exceptions>
+/// MgException
+/// </exceptions>
+///----------------------------------------------------------------------------
+void MgOpExecuteQueryDefinition::Execute()
+{
+    ACE_DEBUG((LM_DEBUG, ACE_TEXT("  (%t) MgOpExecuteQueryDefinition::Execute()\n")));
+
+    MG_LOG_OPERATION_MESSAGE(L"SelectFeatures");
+
+    MG_FEATURE_SERVICE_TRY()
+
+    MG_LOG_OPERATION_MESSAGE_INIT(m_packet.m_OperationVersion, m_packet.m_NumArguments);
+
+    ACE_ASSERT(m_stream != NULL);
+
+    if (2 == m_packet.m_NumArguments)
+    {
+        // Get the feature source
+        Ptr<MgResourceIdentifier> resource = (MgResourceIdentifier*)m_stream->GetObject();
+        // Get the parameters name
+        Ptr<MgPropertyCollection> parameters = (MgPropertyCollection*)m_stream->GetObject();
+        
+        BeginExecution();
+
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == resource) ? L"MgResourceIdentifier" : resource->ToString().c_str());
+        MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(L"MgPropertyCollection");
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+        Validate();
+
+        // Execute the operation
+        Ptr<MgFeatureReader> featureReader = m_service->ExecuteQueryDefinition(resource, parameters);
+
+        // Write the response
+        EndExecution(featureReader);
+    }
+    else if (1 == m_packet.m_NumArguments)
+    {
+        // Get the feature source
+        Ptr<MgResourceIdentifier> resource = (MgResourceIdentifier*)m_stream->GetObject();
+        
+        BeginExecution();
+
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == resource) ? L"MgResourceIdentifier" : resource->ToString().c_str());
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+        Validate();
+
+        // Execute the operation
+        Ptr<MgFeatureReader> featureReader = m_service->ExecuteQueryDefinition(resource);
+
+        // Write the response
+        EndExecution(featureReader);
+    }
+    else
+    {
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+    }
+
+    if (!m_argsRead)
+    {
+        throw new MgOperationProcessingException(L"MgOpExecuteQueryDefinition.Execute",
+            __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    // Successful operation
+    MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Success.c_str());
+
+    MG_FEATURE_SERVICE_CATCH(L"MgOpExecuteQueryDefinition.Execute")
+
+    if (mgException != NULL)
+    {
+        // Failed operation
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(MgResources::Failure.c_str());
+    }
+
+    // Add access log entry for operation
+    MG_LOG_OPERATION_MESSAGE_ACCESS_ENTRY();
+
+    MG_FEATURE_SERVICE_THROW()
+}

Added: sandbox/jng/querydef/Server/src/Services/Feature/OpExecuteQueryDefinition.h
===================================================================
--- sandbox/jng/querydef/Server/src/Services/Feature/OpExecuteQueryDefinition.h	                        (rev 0)
+++ sandbox/jng/querydef/Server/src/Services/Feature/OpExecuteQueryDefinition.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,33 @@
+//
+//  Copyright (C) 2004-2013 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef MG_OP_EXECUTEQUERYDEFINITION_H
+#define MG_OP_EXECUTEQUERYDEFINITION_H
+
+#include "FeatureOperation.h"
+
+class MgOpExecuteQueryDefinition : public MgFeatureOperation
+{
+    public:
+        MgOpExecuteQueryDefinition();
+        virtual ~MgOpExecuteQueryDefinition();
+
+    public:
+        virtual void Execute();
+};
+
+#endif

Modified: sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.cpp
===================================================================
--- sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.cpp	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -514,7 +514,80 @@
     return NULL; // to make some compiler happy
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+/// a MgFeatureReader containing the query results
+///
+/// \remarks
+/// Any parameters that are defined in the Query Definition will assume default values when calling this overload.
+/// Also be sure to Close() the MgFeatureReader object returned by this method.
+///
+/// <!-- Syntax in .Net, Java, and PHP -->
+/// \htmlinclude DotNetSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+/// \htmlinclude JavaSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+/// \htmlinclude PHPSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+///
+/// \param resource (MgResourceIdentifier)
+/// A resource identifier for the Query Definition
+///
+/// \return
+/// Returns an MgFeatureReader containing the results of the executed query
+///
+MgFeatureReader* MgServerFeatureService::ExecuteQueryDefinition(MgResourceIdentifier* resource)
+{
+    throw new MgNotImplementedException(
+        L"MgServerFeatureService::ExecuteQueryDefinition",
+        __LINE__, __WFILE__, NULL, L"", NULL);
 
+    return NULL; // to make some compiler happy
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+/// a MgFeatureReader containing the query results
+///
+/// \remarks
+/// Any parameters that are defined in the Query Definition that are not specified in the parameter collection passed in 
+/// will assume default values when calling this overload.
+/// Also be sure to Close() the MgFeatureReader object returned by this method.
+///
+/// <!-- Syntax in .Net, Java, and PHP -->
+/// \htmlinclude DotNetSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+/// \htmlinclude JavaSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+/// \htmlinclude PHPSyntaxTop.html
+/// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+/// \htmlinclude SyntaxBottom.html
+///
+/// \param resource (MgResourceIdentifier)
+/// A resource identifier for the Query Definition
+///
+/// \param parameters (MgPropertyCollection)
+/// A collection of parameters to pass into this query
+///
+/// \return
+/// Returns an MgFeatureReader containing the results of the executed query
+///
+MgFeatureReader* MgServerFeatureService::ExecuteQueryDefinition(MgResourceIdentifier* resource, MgPropertyCollection* parameters)
+{
+    throw new MgNotImplementedException(
+        L"MgServerFeatureService::ExecuteQueryDefinition",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+
+    return NULL; // to make some compiler happy
+}
+
 //////////////////////////////////////////////////////////////////
 /// <summary>
 /// This operation allows user to select features and then combine them into a group (means aggregate them).

Modified: sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.h
===================================================================
--- sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.h	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -412,6 +412,66 @@
                                     MgFeatureQueryOptions* options,
                                     CREFSTRING coordinateSystem);
 
+    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+    /// a MgFeatureReader containing the query results
+    ///
+    /// \remarks
+    /// Any parameters that are defined in the Query Definition will assume default values when calling this overload.
+    /// Also be sure to Close() the MgFeatureReader object returned by this method.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource (MgResourceIdentifier)
+    /// A resource identifier for the Query Definition
+    ///
+    /// \return
+    /// Returns an MgFeatureReader containing the results of the executed query
+    ///
+    virtual MgFeatureReader* ExecuteQueryDefinition(MgResourceIdentifier* resource);
+
+    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Executes a Feature Source Query as defined in the given Query Definition resource and returns
+    /// a MgFeatureReader containing the query results
+    ///
+    /// \remarks
+    /// Any parameters that are defined in the Query Definition that are not specified in the parameter collection passed in 
+    /// will assume default values when calling this overload.
+    /// Also be sure to Close() the MgFeatureReader object returned by this method.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// virtual MgFeatureReader ExecuteQueryDefinition(MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param resource (MgResourceIdentifier)
+    /// A resource identifier for the Query Definition
+    ///
+    /// \param parameters (MgPropertyCollection)
+    /// A collection of parameters to pass into this query
+    ///
+    /// \return
+    /// Returns an MgFeatureReader containing the results of the executed query
+    ///
+    virtual MgFeatureReader* ExecuteQueryDefinition(MgResourceIdentifier* resource, MgPropertyCollection* parameters);
+
     //////////////////////////////////////////////////////////////////
     /// <summary>
     /// This operation allows user to select features and then combine them into a group (means aggregate them).

Modified: sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.vcxproj
===================================================================
--- sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.vcxproj	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.vcxproj	2013-04-30 15:21:47 UTC (rev 7465)
@@ -295,6 +295,12 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="OpExecuteQueryDefinition.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="OpExecuteSqlNonQuery.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -797,6 +803,7 @@
     <ClInclude Include="OpDescribeSchemaAsXml.h" />
     <ClInclude Include="OpDescribeWfsFeatureType.h" />
     <ClInclude Include="OpEnumerateDataStores.h" />
+    <ClInclude Include="OpExecuteQueryDefinition.h" />
     <ClInclude Include="OpExecuteSqlNonQuery.h" />
     <ClInclude Include="OpExecuteSqlQuery.h" />
     <ClInclude Include="OpGetCapabilities.h" />

Modified: sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.vcxproj.filters
===================================================================
--- sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.vcxproj.filters	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureService.vcxproj.filters	2013-04-30 15:21:47 UTC (rev 7465)
@@ -188,6 +188,9 @@
     <ClCompile Include="ServerUpdateFeatures.cpp" />
     <ClCompile Include="TransformCache.cpp" />
     <ClCompile Include="FdoForcedOneToOneFeatureReader.cpp" />
+    <ClCompile Include="OpExecuteQueryDefinition.cpp">
+      <Filter>Ops</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="FeatureOperation.h">
@@ -385,6 +388,9 @@
     <ClInclude Include="TransformCache.h" />
     <ClInclude Include="UniqueFunction.h" />
     <ClInclude Include="FdoForcedOneToOneFeatureReader.h" />
+    <ClInclude Include="OpExecuteQueryDefinition.h">
+      <Filter>Ops</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="ServerFeatureService.rc" />

Modified: sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureServiceBuild.cpp
===================================================================
--- sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureServiceBuild.cpp	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/Services/Feature/ServerFeatureServiceBuild.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -25,6 +25,7 @@
 #include "OpDescribeSchemaAsXml.cpp"
 #include "OpExecuteSqlNonQuery.cpp"
 #include "OpExecuteSqlQuery.cpp"
+#include "OpExecuteQueryDefinition.cpp"
 #include "OpGetCapabilities.cpp"
 #include "OpGetConnectionPropertyValues.cpp"
 #include "OpGetFdoCacheInfo.cpp"

Modified: sandbox/jng/querydef/Server/src/UnitTesting/TestFeatureService.cpp
===================================================================
--- sandbox/jng/querydef/Server/src/UnitTesting/TestFeatureService.cpp	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/UnitTesting/TestFeatureService.cpp	2013-04-30 15:21:47 UTC (rev 7465)
@@ -84,6 +84,18 @@
             MgResourceIdentifier resourceIdentifier7(L"Library://UnitTests/Data/SavePointTest.FeatureSource");
             MgResourceIdentifier resourceIdentifier8(L"Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource");
             MgResourceIdentifier resourceIdentifier9(L"Library://UnitTests/Data/FdoJoin.FeatureSource");
+
+            MgResourceIdentifier resourceIdentifier12(L"Library://UnitTests/Queries/UT_AggregateCount.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier13(L"Library://UnitTests/Queries/UT_AggregateSpatialExtents.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier14(L"Library://UnitTests/Queries/UT_BasicAllElements.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier15(L"Library://UnitTests/Queries/UT_BasicBarebones.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier16(L"Library://UnitTests/Queries/UT_BasicMinimal.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier17(L"Library://UnitTests/Queries/UT_BasicWithExplicitPropertyList.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier18(L"Library://UnitTests/Queries/UT_BasicWithFilter.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier19(L"Library://UnitTests/Queries/UT_SQLAggregate.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier20(L"Library://UnitTests/Queries/UT_SQLBasic.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier21(L"Library://UnitTests/Queries/UT_SQLWhere.QueryDefinition");
+            MgResourceIdentifier resourceIdentifier22(L"Library://UnitTests/Queries/UT_SQLWhereJoin.QueryDefinition");
 #ifdef _WIN32
             STRING resourceContentFileName1 = L"..\\UnitTestFiles\\Sheboygan_Parcels.FeatureSource";
             STRING resourceContentFileName2 = L"..\\UnitTestFiles\\Redding_Parcels.FeatureSource";
@@ -104,6 +116,18 @@
             STRING dataFileName8 = L"..\\UnitTestFiles\\SavePointTest.sqlite";
             STRING dataFileName9 = L"..\\UnitTestFiles\\JoinTest.sqlite";
             STRING dataFileName10 = L"..\\UnitTestFiles\\ParcelsJoinTest.sqlite";
+
+            STRING dataFileName12 = L"..\\UnitTestFiles\\UT_AggregateCount.QueryDefinition";
+            STRING dataFileName13 = L"..\\UnitTestFiles\\UT_AggregateSpatialExtents.QueryDefinition";
+            STRING dataFileName14 = L"..\\UnitTestFiles\\UT_BasicAllElements.QueryDefinition";
+            STRING dataFileName15 = L"..\\UnitTestFiles\\UT_BasicBarebones.QueryDefinition";
+            STRING dataFileName16 = L"..\\UnitTestFiles\\UT_BasicMinimal.QueryDefinition";
+            STRING dataFileName17 = L"..\\UnitTestFiles\\UT_BasicWithExplicitPropertyList.QueryDefinition";
+            STRING dataFileName18 = L"..\\UnitTestFiles\\UT_BasicWithFilter.QueryDefinition";
+            STRING dataFileName19 = L"..\\UnitTestFiles\\UT_SQLAggregate.QueryDefinition";
+            STRING dataFileName20 = L"..\\UnitTestFiles\\UT_SQLBasic.QueryDefinition";
+            STRING dataFileName21 = L"..\\UnitTestFiles\\UT_SQLWhere.QueryDefinition";
+            STRING dataFileName22 = L"..\\UnitTestFiles\\UT_SQLWhereJoin.QueryDefinition";
 #else
             STRING resourceContentFileName1 = L"../UnitTestFiles/Sheboygan_Parcels.FeatureSource";
             STRING resourceContentFileName2 = L"../UnitTestFiles/Redding_Parcels.FeatureSource";
@@ -124,6 +148,18 @@
             STRING dataFileName8 = L"../UnitTestFiles/SavePointTest.sqlite";
             STRING dataFileName9 = L"../UnitTestFiles/JoinTest.sqlite";
             STRING dataFileName10 = L"../UnitTestFiles/ParcelsJoinTest.sqlite";
+
+            STRING dataFileName12 = L"../UnitTestFiles/UT_AggregateCount.QueryDefinition";
+            STRING dataFileName13 = L"../UnitTestFiles/UT_AggregateSpatialExtents.QueryDefinition";
+            STRING dataFileName14 = L"../UnitTestFiles/UT_BasicAllElements.QueryDefinition";
+            STRING dataFileName15 = L"../UnitTestFiles/UT_BasicBarebones.QueryDefinition";
+            STRING dataFileName16 = L"../UnitTestFiles/UT_BasicMinimal.QueryDefinition";
+            STRING dataFileName17 = L"../UnitTestFiles/UT_BasicWithExplicitPropertyList.QueryDefinition";
+            STRING dataFileName18 = L"../UnitTestFiles/UT_BasicWithFilter.QueryDefinition";
+            STRING dataFileName19 = L"../UnitTestFiles/UT_SQLAggregate.QueryDefinition";
+            STRING dataFileName20 = L"../UnitTestFiles/UT_SQLBasic.QueryDefinition";
+            STRING dataFileName21 = L"../UnitTestFiles/UT_SQLWhere.QueryDefinition";
+            STRING dataFileName22 = L"../UnitTestFiles/UT_SQLWhereJoin.QueryDefinition";
 #endif
 
             //Add a new resource
@@ -207,6 +243,50 @@
             Ptr<MgByteSource> dataSource11 = new MgByteSource(dataFileName10);
             Ptr<MgByteReader> dataReader11 = dataSource11->GetReader();
             pService->SetResourceData(&resourceIdentifier8, L"ParcelsJoinTest.sqlite", L"File", dataReader11);
+
+            Ptr<MgByteSource> contentSource12 = new MgByteSource(dataFileName12);
+            Ptr<MgByteReader> contentReader12 = contentSource12->GetReader();
+            pService->SetResource(&resourceIdentifier12, contentReader12, NULL);
+
+            Ptr<MgByteSource> contentSource13 = new MgByteSource(dataFileName13);
+            Ptr<MgByteReader> contentReader13 = contentSource13->GetReader();
+            pService->SetResource(&resourceIdentifier13, contentReader13, NULL);
+
+            Ptr<MgByteSource> contentSource14 = new MgByteSource(dataFileName14);
+            Ptr<MgByteReader> contentReader14 = contentSource14->GetReader();
+            pService->SetResource(&resourceIdentifier14, contentReader14, NULL);
+
+            Ptr<MgByteSource> contentSource15 = new MgByteSource(dataFileName15);
+            Ptr<MgByteReader> contentReader15 = contentSource15->GetReader();
+            pService->SetResource(&resourceIdentifier15, contentReader15, NULL);
+
+            Ptr<MgByteSource> contentSource16 = new MgByteSource(dataFileName16);
+            Ptr<MgByteReader> contentReader16 = contentSource16->GetReader();
+            pService->SetResource(&resourceIdentifier16, contentReader16, NULL);
+
+            Ptr<MgByteSource> contentSource17 = new MgByteSource(dataFileName17);
+            Ptr<MgByteReader> contentReader17 = contentSource17->GetReader();
+            pService->SetResource(&resourceIdentifier17, contentReader17, NULL);
+
+            Ptr<MgByteSource> contentSource18 = new MgByteSource(dataFileName18);
+            Ptr<MgByteReader> contentReader18 = contentSource18->GetReader();
+            pService->SetResource(&resourceIdentifier18, contentReader18, NULL);
+
+            Ptr<MgByteSource> contentSource19 = new MgByteSource(dataFileName19);
+            Ptr<MgByteReader> contentReader19 = contentSource19->GetReader();
+            pService->SetResource(&resourceIdentifier19, contentReader19, NULL);
+
+            Ptr<MgByteSource> contentSource20 = new MgByteSource(dataFileName20);
+            Ptr<MgByteReader> contentReader20 = contentSource20->GetReader();
+            pService->SetResource(&resourceIdentifier20, contentReader20, NULL);
+
+            Ptr<MgByteSource> contentSource21 = new MgByteSource(dataFileName21);
+            Ptr<MgByteReader> contentReader21 = contentSource21->GetReader();
+            pService->SetResource(&resourceIdentifier21, contentReader21, NULL);
+
+            Ptr<MgByteSource> contentSource22 = new MgByteSource(dataFileName22);
+            Ptr<MgByteReader> contentReader22 = contentSource22->GetReader();
+            pService->SetResource(&resourceIdentifier22, contentReader22, NULL);
         }
     }
     catch(MgException* e)
@@ -273,6 +353,39 @@
         Ptr<MgResourceIdentifier> fsres10 = new MgResourceIdentifier(L"Library://UnitTests/Data/TestInsert.FeatureSource");
         if (pService->ResourceExists(fsres10)) pService->DeleteResource(fsres10);
 
+        MgResourceIdentifier resourceIdentifier12(L"Library://UnitTests/Queries/UT_AggregateCount.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier12);
+
+        MgResourceIdentifier resourceIdentifier13(L"Library://UnitTests/Queries/UT_AggregateSpatialExtents.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier13);
+
+        MgResourceIdentifier resourceIdentifier14(L"Library://UnitTests/Queries/UT_BasicAllElements.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier14);
+
+        MgResourceIdentifier resourceIdentifier15(L"Library://UnitTests/Queries/UT_BasicBarebones.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier15);
+
+        MgResourceIdentifier resourceIdentifier16(L"Library://UnitTests/Queries/UT_BasicMinimal.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier16);
+
+        MgResourceIdentifier resourceIdentifier17(L"Library://UnitTests/Queries/UT_BasicWithExplicitPropertyList.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier17);
+
+        MgResourceIdentifier resourceIdentifier18(L"Library://UnitTests/Queries/UT_BasicWithFilter.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier18);
+
+        MgResourceIdentifier resourceIdentifier19(L"Library://UnitTests/Queries/UT_SQLAggregate.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier19);
+
+        MgResourceIdentifier resourceIdentifier20(L"Library://UnitTests/Queries/UT_SQLBasic.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier20);
+
+        MgResourceIdentifier resourceIdentifier21(L"Library://UnitTests/Queries/UT_SQLWhere.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier21);
+
+        MgResourceIdentifier resourceIdentifier22(L"Library://UnitTests/Queries/UT_SQLWhereJoin.QueryDefinition");
+        pService->DeleteResource(&resourceIdentifier22);
+
         #ifdef _DEBUG
         ACE_DEBUG((LM_INFO, ACE_TEXT("TestFeatureService::TestEnd()\n")));
         MgFdoConnectionManager* pFdoConnectionManager = MgFdoConnectionManager::GetInstance();
@@ -2965,4 +3078,1848 @@
     {
         throw;
     }
+}
+
+void TestFeatureService::TestCase_QueryAggregateCount()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QueryAggregateCount", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QueryAggregateCount", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+        
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_AggregateCount.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(1 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(0 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"RecordCount") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"RecordCount") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"RecordCount") >= 0);
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Query does not define GeometryInfo so there's nothing here
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Query does not define GeometryInfo so there's nothing here
+        scReader->Close();
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(1 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"RecordCount") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == clsProps->GetCount());
+        CPPUNIT_ASSERT(0 == idProps->GetCount());
+
+        bRead = fr->ReadNext();
+        CPPUNIT_ASSERT(bRead);
+
+        INT64 count = fr->GetInt64(L"RecordCount");
+        INT64 count2 = fr->GetInt64(fr->GetPropertyIndex(L"RecordCount"));
+        CPPUNIT_ASSERT(17565L == count);
+        CPPUNIT_ASSERT(count == count2);
+        bRead  = fr->ReadNext();
+        CPPUNIT_ASSERT(!bRead);
+        fr->Close();
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QueryAggregateSpatialExtents()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QueryAggregateSpatialExtents", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QueryAggregateSpatialExtents", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_AggregateSpatialExtents.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(1 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(0 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"MyExtents") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"MyExtents") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"MyExtents") >= 0);
+        //Should be designated
+        CPPUNIT_ASSERT(L"MyExtents" == klass->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"MyExtents" == klass2->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"MyExtents" == klass3->GetDefaultGeometryPropertyName());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"MyExtents");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"MyExtents");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"MyExtents");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop2.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop3.p)->GetGeometryTypes());
+        //Spatial context association should match
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"Default" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        Ptr<MgByteReader> scAgf = scReader->GetExtent();
+        Ptr<MgGeometry> scGeom = agfRw->Read(scAgf);
+        Ptr<MgEnvelope> scEnv = scGeom->Envelope();
+        Ptr<MgCoordinate> scEnvLL = scEnv->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"Default" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        scAgf = scReader->GetExtent();
+        scGeom = agfRw->Read(scAgf);
+        scEnv = scGeom->Envelope();
+        scEnvLL = scEnv->GetLowerLeftCoordinate();
+        scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        scReader->Close();
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(1 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"MyExtents") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == clsProps->GetCount());
+        CPPUNIT_ASSERT(0 == idProps->GetCount());
+
+        bRead = fr->ReadNext();
+        CPPUNIT_ASSERT(bRead);
+
+        //Huh? MgFeatureReader inherits MgReader! Why you don't let me?
+        Ptr<MgByteReader> bbox = ((MgReader*)fr)->GetGeometry(L"MyExtents");
+        Ptr<MgByteReader> bbox2 = ((MgReader*)fr)->GetGeometry(fr->GetPropertyIndex(L"MyExtents"));
+        CPPUNIT_ASSERT(bbox == bbox2);
+        bRead  = fr->ReadNext();
+        CPPUNIT_ASSERT(!bRead);
+        fr->Close();
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QueryBasicAllElements()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QueryBasicAllElements", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QueryBasicAllElements", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_BasicAllElements.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(3 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassIdProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"MyCurrentDate") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"MyCurrentDate") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"MyCurrentDate") >= 0);
+        //Should be designated
+        CPPUNIT_ASSERT(L"Geometry" == klass->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass2->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass3->GetDefaultGeometryPropertyName());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"Geometry");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop2.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop3.p)->GetGeometryTypes());
+        //Spatial context association should match
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        Ptr<MgByteReader> scAgf = scReader->GetExtent();
+        Ptr<MgGeometry> scGeom = agfRw->Read(scAgf);
+        Ptr<MgEnvelope> scEnv = scGeom->Envelope();
+        Ptr<MgCoordinate> scEnvLL = scEnv->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        scAgf = scReader->GetExtent();
+        scGeom = agfRw->Read(scAgf);
+        scEnv = scGeom->Envelope();
+        scEnvLL = scEnv->GetLowerLeftCoordinate();
+        scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        scReader->Close();
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(3 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"MyCurrentDate") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(3 == clsProps->GetCount());
+        CPPUNIT_ASSERT(1 == idProps->GetCount());
+        CPPUNIT_ASSERT(idProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"MyCurrentDate") >= 0);
+
+        //Filter defined in the query should yield 80 results
+        INT32 count = 0;
+        while(fr->ReadNext()) {
+            count++;
+        }
+        fr->Close();
+        CPPUNIT_ASSERT(80 == count);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QueryBasicBarebones()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QueryBasicAllElements", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QueryBasicAllElements", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_BasicBarebones.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(3 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassIdProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"ID") >= 0);
+        //Should not be designated because Query did not supply GeometryInfo
+        CPPUNIT_ASSERT(klass->GetDefaultGeometryPropertyName().empty());
+        CPPUNIT_ASSERT(klass->GetDefaultGeometryPropertyName().empty());
+        CPPUNIT_ASSERT(klass->GetDefaultGeometryPropertyName().empty());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"Geometry");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        //Spatial context association should be blank because Query did not supply GeometryInfo
+        CPPUNIT_ASSERT(((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation().empty());
+        CPPUNIT_ASSERT(((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation().empty());
+        CPPUNIT_ASSERT(((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation().empty());
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Query has no GeometryInfo so we shouldn't have a result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Query has no GeometryInfo so we shouldn't have a result
+        scReader->Close();
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(3 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"MyCurrentDate") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(3 == clsProps->GetCount());
+        CPPUNIT_ASSERT(1 == idProps->GetCount());
+        CPPUNIT_ASSERT(idProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"MyCurrentDate") >= 0);
+
+        INT32 count = 0;
+        while(fr->ReadNext()) {
+            count++;
+        }
+        fr->Close();
+        CPPUNIT_ASSERT(17565 == count);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QueryBasicMinimal()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QueryBasicMinimal", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QueryBasicMinimal", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_BasicMinimal.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(3 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassIdProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"ID") >= 0);
+        //Should be designated
+        CPPUNIT_ASSERT(L"Geometry" == klass->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass2->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass3->GetDefaultGeometryPropertyName());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"Geometry");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop2.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop3.p)->GetGeometryTypes());
+        //Spatial context association should match
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        Ptr<MgByteReader> scAgf = scReader->GetExtent();
+        Ptr<MgGeometry> scGeom = agfRw->Read(scAgf);
+        Ptr<MgEnvelope> scEnv = scGeom->Envelope();
+        Ptr<MgCoordinate> scEnvLL = scEnv->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        scAgf = scReader->GetExtent();
+        scGeom = agfRw->Read(scAgf);
+        scEnv = scGeom->Envelope();
+        scEnvLL = scEnv->GetLowerLeftCoordinate();
+        scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        scReader->Close();
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(3 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"ID") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(3 == clsProps->GetCount());
+        CPPUNIT_ASSERT(1 == idProps->GetCount());
+        CPPUNIT_ASSERT(idProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"ID") >= 0);
+
+        INT32 count = 0;
+        while(fr->ReadNext()) {
+            count++;
+        }
+        fr->Close();
+        CPPUNIT_ASSERT(17565 == count);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QueryBasicWithExplicitPropertyList()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QueryBasicWithExplicitPropertyList", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QueryBasicWithExplicitPropertyList", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_BasicWithExplicitPropertyList.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(5 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassIdProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"MyCurrentDate") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"MyCurrentDate") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"MyCurrentDate") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"MyIDLength") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"MyIDLength") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"MyIDLength") >= 0);
+        //Should be designated
+        CPPUNIT_ASSERT(L"Geometry" == klass->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass2->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass3->GetDefaultGeometryPropertyName());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"Geometry");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop2.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop3.p)->GetGeometryTypes());
+        //Spatial context association should match
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        Ptr<MgByteReader> scAgf = scReader->GetExtent();
+        Ptr<MgGeometry> scGeom = agfRw->Read(scAgf);
+        Ptr<MgEnvelope> scEnv = scGeom->Envelope();
+        Ptr<MgCoordinate> scEnvLL = scEnv->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        scAgf = scReader->GetExtent();
+        scGeom = agfRw->Read(scAgf);
+        scEnv = scGeom->Envelope();
+        scEnvLL = scEnv->GetLowerLeftCoordinate();
+        scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        scReader->Close();
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(5 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"ID") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(5 == clsProps->GetCount());
+        CPPUNIT_ASSERT(1 == idProps->GetCount());
+        CPPUNIT_ASSERT(idProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"MyCurrentDate") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"MyIDLength") >= 0);
+
+        INT32 count = 0;
+        while(fr->ReadNext()) {
+            count++;
+        }
+        fr->Close();
+        CPPUNIT_ASSERT(17565 == count);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QueryBasicWithFilter()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QueryBasicWithFilter", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QueryBasicWithFilter", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_BasicWithFilter.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(3 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassIdProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"ID") >= 0);
+        //Should be designated
+        CPPUNIT_ASSERT(L"Geometry" == klass->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass2->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass3->GetDefaultGeometryPropertyName());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"Geometry");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop2.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop3.p)->GetGeometryTypes());
+        //Spatial context association should match
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        Ptr<MgByteReader> scAgf = scReader->GetExtent();
+        Ptr<MgGeometry> scGeom = agfRw->Read(scAgf);
+        Ptr<MgEnvelope> scEnv = scGeom->Envelope();
+        Ptr<MgCoordinate> scEnvLL = scEnv->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        scAgf = scReader->GetExtent();
+        scGeom = agfRw->Read(scAgf);
+        scEnv = scGeom->Envelope();
+        scEnvLL = scEnv->GetLowerLeftCoordinate();
+        scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        scReader->Close();
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(3 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"ID") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(3 == clsProps->GetCount());
+        CPPUNIT_ASSERT(1 == idProps->GetCount());
+        CPPUNIT_ASSERT(idProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"ID") >= 0);
+
+        //Filter in query should result in 80 records
+        INT32 count = 0;
+        while(fr->ReadNext()) {
+            count++;
+        }
+        fr->Close();
+        CPPUNIT_ASSERT(80 == count);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QuerySQLAggregate()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QuerySQLAggregate", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QuerySQLAggregate", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_SQLAggregate.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(1 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(0 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"RecordCount") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"RecordCount") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"RecordCount") >= 0);
+        //Should have nothing designated
+        CPPUNIT_ASSERT(klass->GetDefaultGeometryPropertyName().empty());
+        CPPUNIT_ASSERT(klass2->GetDefaultGeometryPropertyName().empty());
+        CPPUNIT_ASSERT(klass3->GetDefaultGeometryPropertyName().empty());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead);
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead);
+        scReader->Close();
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(1 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"RecordCount") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == clsProps->GetCount());
+        CPPUNIT_ASSERT(0 == idProps->GetCount());
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"RecordCount") >= 0);
+
+        INT32 count = 0;
+        bRead = fr->ReadNext();
+        CPPUNIT_ASSERT(bRead);
+        count = (INT32)fr->GetInt64(L"RecordCount");
+        CPPUNIT_ASSERT(17565 == count);
+        bRead = fr->ReadNext();
+        CPPUNIT_ASSERT(!bRead);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QuerySQLBasic()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QuerySQLBasic", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QuerySQLBasic", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        //NOTE: Not all FDO providers may do this (correctly interpret geom columns). But those that do should also pass these tests.
+        //It's a good thing SQLite is a model FDO provider that all others should look to
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_SQLBasic.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(3 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassIdProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"ID") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"ID") >= 0);
+        //Should be designated
+        CPPUNIT_ASSERT(L"Geometry" == klass->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass2->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass3->GetDefaultGeometryPropertyName());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"Geometry");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop2.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop3.p)->GetGeometryTypes());
+        //Spatial context association should match
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        Ptr<MgByteReader> scAgf = scReader->GetExtent();
+        Ptr<MgGeometry> scGeom = agfRw->Read(scAgf);
+        Ptr<MgEnvelope> scEnv = scGeom->Envelope();
+        Ptr<MgCoordinate> scEnvLL = scEnv->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        scAgf = scReader->GetExtent();
+        scGeom = agfRw->Read(scAgf);
+        scEnv = scGeom->Envelope();
+        scEnvLL = scEnv->GetLowerLeftCoordinate();
+        scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        scReader->Close();
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(3 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"ID") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(3 == clsProps->GetCount());
+        CPPUNIT_ASSERT(1 == idProps->GetCount());
+        CPPUNIT_ASSERT(idProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"ID") >= 0);
+
+        INT32 count = 0;
+        while(fr->ReadNext()) {
+            count++;
+        }
+        fr->Close();
+        CPPUNIT_ASSERT(17565 == count);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QuerySQLWhere()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QuerySQLWhere", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QuerySQLWhere", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        //NOTE: Not all FDO providers may do this (correctly interpret geom columns). But those that do should also pass these tests.
+        //It's a good thing SQLite is a model FDO provider that all others should look to
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_SQLWhere.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(3 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassIdProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"current_date") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"current_date") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"current_date") >= 0);
+        //Should be designated
+        CPPUNIT_ASSERT(L"Geometry" == klass->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass2->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass3->GetDefaultGeometryPropertyName());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"Geometry");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop2.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop3.p)->GetGeometryTypes());
+        //Spatial context association should match
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        Ptr<MgByteReader> scAgf = scReader->GetExtent();
+        Ptr<MgGeometry> scGeom = agfRw->Read(scAgf);
+        Ptr<MgEnvelope> scEnv = scGeom->Envelope();
+        Ptr<MgCoordinate> scEnvLL = scEnv->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        scAgf = scReader->GetExtent();
+        scGeom = agfRw->Read(scAgf);
+        scEnv = scGeom->Envelope();
+        scEnvLL = scEnv->GetLowerLeftCoordinate();
+        scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        scReader->Close();
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(3 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"current_date") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(3 == clsProps->GetCount());
+        CPPUNIT_ASSERT(1 == idProps->GetCount());
+        CPPUNIT_ASSERT(idProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"current_date") >= 0);
+
+        //Our where clause should cut the result set down to 80 records
+        INT32 count = 0;
+        while(fr->ReadNext()) {
+            count++;
+        }
+        fr->Close();
+        CPPUNIT_ASSERT(80 == count);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
+}
+
+void TestFeatureService::TestCase_QuerySQLWhereJoin()
+{
+    try
+    {
+        MgServiceManager* serviceManager = MgServiceManager::GetInstance();
+        if(serviceManager == 0)
+        {
+            throw new MgNullReferenceException(L"TestFeatureService.TestCase_QuerySQLWhereJoin", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        Ptr<MgFeatureService> pService = dynamic_cast<MgFeatureService*>(serviceManager->RequestService(MgServiceType::FeatureService));
+        if (pService == 0)
+        {
+            throw new MgServiceNotAvailableException(L"TestFeatureService.TestCase_QuerySQLWhereJoin", __LINE__, __WFILE__, NULL, L"", NULL);
+        }
+
+        //NOTE: Not all FDO providers may do this (correctly interpret geom columns). But those that do should also pass these tests.
+        //It's a good thing SQLite is a model FDO provider that all others should look to
+
+        Ptr<MgResourceIdentifier> qryId = new MgResourceIdentifier(L"Library://UnitTests/Queries/UT_SQLWhereJoin.QueryDefinition");
+        //Test the structure
+        Ptr<MgStringCollection> classNames = new MgStringCollection();
+        classNames->Add(L"Query");
+        Ptr<MgFeatureSchemaCollection> schemas = pService->DescribeSchema(qryId, L"");
+        Ptr<MgFeatureSchemaCollection> schemas2 = pService->DescribeSchema(qryId, L"Default");
+        Ptr<MgFeatureSchemaCollection> schemas3 = pService->DescribeSchema(qryId, L"Default", classNames);
+        CPPUNIT_ASSERT(1 == schemas->GetCount());
+        CPPUNIT_ASSERT(schemas->GetCount() == schemas2->GetCount());
+        CPPUNIT_ASSERT(schemas3->GetCount() == schemas2->GetCount());
+        Ptr<MgFeatureSchema> schema = schemas->GetItem(0);
+        Ptr<MgFeatureSchema> schema2 = schemas2->GetItem(0);
+        Ptr<MgFeatureSchema> schema3 = schemas3->GetItem(0);
+        CPPUNIT_ASSERT(L"Default" == schema->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema2->GetName());
+        CPPUNIT_ASSERT(L"Default" == schema3->GetName());
+        Ptr<MgClassDefinitionCollection> classes = schema->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes2 = schema2->GetClasses();
+        Ptr<MgClassDefinitionCollection> classes3 = schema3->GetClasses();
+        CPPUNIT_ASSERT(1 == classes->GetCount());
+        CPPUNIT_ASSERT(classes->GetCount() == classes2->GetCount());
+        CPPUNIT_ASSERT(classes3->GetCount() == classes2->GetCount());
+        Ptr<MgClassDefinition> klass = classes->GetItem(0);
+        Ptr<MgClassDefinition> klass2 = classes2->GetItem(0);
+        Ptr<MgClassDefinition> klass3 = classes3->GetItem(0);
+        CPPUNIT_ASSERT(L"Query" == klass->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass2->GetName());
+        CPPUNIT_ASSERT(L"Query" == klass3->GetName());
+        Ptr<MgPropertyDefinitionCollection> klassProps = klass->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps2 = klass2->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> klassProps3 = klass3->GetProperties();
+        CPPUNIT_ASSERT(7 == klassProps->GetCount());
+        CPPUNIT_ASSERT(klassProps->GetCount() == klassProps2->GetCount());
+        CPPUNIT_ASSERT(klassProps3->GetCount() == klassProps2->GetCount());
+        Ptr<MgPropertyDefinitionCollection> klassIdProps = klass->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps2 = klass2->GetIdentityProperties();
+        Ptr<MgPropertyDefinitionCollection> klassIdProps3 = klass3->GetIdentityProperties();
+        CPPUNIT_ASSERT(1 == klassIdProps->GetCount());
+        CPPUNIT_ASSERT(klassIdProps->GetCount() == klassIdProps2->GetCount());
+        CPPUNIT_ASSERT(klassIdProps3->GetCount() == klassIdProps2->GetCount());
+        //Our property should be here
+        CPPUNIT_ASSERT(klassIdProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassIdProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"current_date") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"current_date") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"current_date") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"NAME") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"NAME") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"NAME") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"RACRE") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"RACRE") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"RACRE") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"RBILAD") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"RBILAD") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"RBILAD") >= 0);
+        CPPUNIT_ASSERT(klassProps->IndexOf(L"RTYPE") >= 0);
+        CPPUNIT_ASSERT(klassProps2->IndexOf(L"RTYPE") >= 0);
+        CPPUNIT_ASSERT(klassProps3->IndexOf(L"RTYPE") >= 0);
+        //Should be designated
+        CPPUNIT_ASSERT(L"Geometry" == klass->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass2->GetDefaultGeometryPropertyName());
+        CPPUNIT_ASSERT(L"Geometry" == klass3->GetDefaultGeometryPropertyName());
+        //Inspect the geom
+        Ptr<MgPropertyDefinition> prop = klassProps->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop2 = klassProps2->GetItem(L"Geometry");
+        Ptr<MgPropertyDefinition> prop3 = klassProps3->GetItem(L"Geometry");
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop2->GetPropertyType());
+        CPPUNIT_ASSERT(MgFeaturePropertyType::GeometricProperty == prop3->GetPropertyType());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop2.p)->GetGeometryTypes());
+        CPPUNIT_ASSERT(7 == ((MgGeometricPropertyDefinition*)prop3.p)->GetGeometryTypes());
+        //Spatial context association should match
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop2.p)->GetSpatialContextAssociation());
+        CPPUNIT_ASSERT(L"QueryDefault" == ((MgGeometricPropertyDefinition*)prop3.p)->GetSpatialContextAssociation());
+
+        Ptr<MgAgfReaderWriter> agfRw = new MgAgfReaderWriter();
+
+        //Test spatial contexts
+        Ptr<MgSpatialContextReader> scReader = pService->GetSpatialContexts(qryId, false);
+        bool bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        Ptr<MgByteReader> scAgf = scReader->GetExtent();
+        Ptr<MgGeometry> scGeom = agfRw->Read(scAgf);
+        Ptr<MgEnvelope> scEnv = scGeom->Envelope();
+        Ptr<MgCoordinate> scEnvLL = scEnv->GetLowerLeftCoordinate();
+        Ptr<MgCoordinate> scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+        scReader->Close();
+        scReader = pService->GetSpatialContexts(qryId, true); //Doesn't matter, should be the same
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(bRead); //Query has GeometryInfo so we should have a result
+        //Test spatial context reader contents. Should match what we have defined in GeometryInfo
+        CPPUNIT_ASSERT(L"QueryDefault" == scReader->GetName());
+        CPPUNIT_ASSERT(L"Spatial Context for Query Definition" == scReader->GetName());
+        CPPUNIT_ASSERT(L"LL84" == scReader->GetName());
+        CPPUNIT_ASSERT(L"GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]" == scReader->GetName());
+        CPPUNIT_ASSERT(MgSpatialContextExtentType::scDynamic == scReader->GetExtentType());
+        scAgf = scReader->GetExtent();
+        scGeom = agfRw->Read(scAgf);
+        scEnv = scGeom->Envelope();
+        scEnvLL = scEnv->GetLowerLeftCoordinate();
+        scEnvUR = scEnv->GetUpperRightCoordinate();
+        CPPUNIT_ASSERT(-180 == scEnvLL->GetX());
+        CPPUNIT_ASSERT(-90 == scEnvLL->GetY());
+        CPPUNIT_ASSERT(180 == scEnvUR->GetX());
+        CPPUNIT_ASSERT(90 == scEnvUR->GetY());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetXYTolerance());
+        CPPUNIT_ASSERT(0.000001 == scReader->GetZTolerance());
+        scReader->Close();
+        bRead = scReader->ReadNext();
+        CPPUNIT_ASSERT(!bRead); //Only one result
+
+        //Execute the query
+        Ptr<MgFeatureReader> fr = pService->ExecuteQueryDefinition(qryId);
+        //Verify class definition and reader structure
+        CPPUNIT_ASSERT(7 == fr->GetPropertyCount());
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"current_date") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"NAME") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"RACRE") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"RBILAD") >= 0);
+        CPPUNIT_ASSERT(fr->GetPropertyIndex(L"RTYPE") >= 0);
+        Ptr<MgClassDefinition> clsDef = fr->GetClassDefinition();
+        Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
+        Ptr<MgPropertyDefinitionCollection> idProps = clsDef->GetIdentityProperties();
+        CPPUNIT_ASSERT(7 == clsProps->GetCount());
+        CPPUNIT_ASSERT(1 == idProps->GetCount());
+        CPPUNIT_ASSERT(idProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"Geometry") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"SdfId") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"current_date") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"NAME") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"RACRE") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"RBILAD") >= 0);
+        CPPUNIT_ASSERT(clsProps->IndexOf(L"RTYPE") >= 0);
+
+        //Our where clause should cut the result set down to 80 records
+        INT32 count = 0;
+        while(fr->ReadNext()) {
+            count++;
+        }
+        fr->Close();
+        CPPUNIT_ASSERT(80 == count);
+    }
+    catch(MgException* e)
+    {
+        STRING message = e->GetDetails(TEST_LOCALE);
+        SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(FdoException* e)
+    {
+        STRING message = L"FdoException occurred: ";
+        message += e->GetExceptionMessage();
+        FDO_SAFE_RELEASE(e);
+        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+    }
+    catch(...)
+    {
+        throw;
+    }
 }
\ No newline at end of file

Modified: sandbox/jng/querydef/Server/src/UnitTesting/TestFeatureService.h
===================================================================
--- sandbox/jng/querydef/Server/src/UnitTesting/TestFeatureService.h	2013-04-24 17:51:37 UTC (rev 7464)
+++ sandbox/jng/querydef/Server/src/UnitTesting/TestFeatureService.h	2013-04-30 15:21:47 UTC (rev 7465)
@@ -24,7 +24,7 @@
 {
     CPPUNIT_TEST_SUITE(TestFeatureService);
     CPPUNIT_TEST(TestStart); // This must be the very first unit test
-
+    
     CPPUNIT_TEST(TestCase_GetFeatureProviders);
     CPPUNIT_TEST(TestCase_TestConnectionSDFProvider);
     CPPUNIT_TEST(TestCase_TestFdoConnectionManager);
@@ -59,10 +59,23 @@
     CPPUNIT_TEST(TestCase_BenchmarkSelectFeatures);
     CPPUNIT_TEST(TestCase_ConcurrentAccess);
     CPPUNIT_TEST(TestCase_SavePoint);
+    
+    CPPUNIT_TEST(TestCase_QueryAggregateCount);
+    CPPUNIT_TEST(TestCase_QueryAggregateSpatialExtents);
+    CPPUNIT_TEST(TestCase_QueryBasicAllElements);
+    CPPUNIT_TEST(TestCase_QueryBasicBarebones);
+    CPPUNIT_TEST(TestCase_QueryBasicMinimal);
+    CPPUNIT_TEST(TestCase_QueryBasicWithExplicitPropertyList);
+    CPPUNIT_TEST(TestCase_QueryBasicWithFilter);
+    CPPUNIT_TEST(TestCase_QuerySQLAggregate);
+    CPPUNIT_TEST(TestCase_QuerySQLBasic);
+    CPPUNIT_TEST(TestCase_QuerySQLWhere);
+    CPPUNIT_TEST(TestCase_QuerySQLWhereJoin);
+    
     CPPUNIT_TEST(TestCase_JoinFdoFeatures);
     CPPUNIT_TEST(TestCase_BenchmarkSqliteJoin);
     CPPUNIT_TEST(TestCase_BenchmarkSqliteAggregateJoin);
-
+    
     CPPUNIT_TEST(TestEnd); // This must be the very last unit test
     CPPUNIT_TEST_SUITE_END();
 
@@ -107,6 +120,19 @@
     void TestCase_BenchmarkSelectFeatures();
     void TestCase_ConcurrentAccess();
     void TestCase_SavePoint();
+
+    void TestCase_QueryAggregateCount();
+    void TestCase_QueryAggregateSpatialExtents();
+    void TestCase_QueryBasicAllElements();
+    void TestCase_QueryBasicBarebones();
+    void TestCase_QueryBasicMinimal();
+    void TestCase_QueryBasicWithExplicitPropertyList();
+    void TestCase_QueryBasicWithFilter();
+    void TestCase_QuerySQLAggregate();
+    void TestCase_QuerySQLBasic();
+    void TestCase_QuerySQLWhere();
+    void TestCase_QuerySQLWhereJoin();
+
     void TestCase_JoinFdoFeatures();
     void TestCase_BenchmarkSqliteJoin();
     void TestCase_BenchmarkSqliteAggregateJoin();

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_AggregateCount.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_AggregateCount.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_AggregateCount.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <AggregateQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <FeatureClass>Default:ParcelFeatures</FeatureClass>
+    <Filter>ToInt32(SdfId) < 81</Filter>
+    <ComputedProperties>
+      <ComputedProperty>
+        <Name>RecordCount</Name>
+        <Expression>Count(SdfId)</Expression>
+      </ComputedProperty>
+    </ComputedProperties>
+  </AggregateQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_AggregateSpatialExtents.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_AggregateSpatialExtents.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_AggregateSpatialExtents.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <AggregateQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <GeometryInfo>
+      <Geometry>MyExtents</Geometry>
+      <GeometryTypes>7</GeometryTypes>
+      <SpatialContext>
+        <Name>QueryDefault</Name>
+        <Description>Spatial Context for Query Definition</Description>
+        <CoordinateSystemName>LL84</CoordinateSystemName>
+        <CoordinateSystemWkt>GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</CoordinateSystemWkt>
+        <ExtentType>Dynamic</ExtentType>
+        <Extent>
+          <LowerLeftCoordinate>
+            <X>-180</X>
+            <Y>-90</Y>
+          </LowerLeftCoordinate>
+          <UpperRightCoordinate>
+            <X>180</X>
+            <Y>90</Y>
+          </UpperRightCoordinate>
+        </Extent>
+        <XYTolerance>0.000001</XYTolerance>
+        <ZTolerance>0.000001</ZTolerance>
+      </SpatialContext>
+    </GeometryInfo>
+    <FeatureClass>Default:ParcelFeatures</FeatureClass>
+    <ComputedProperties>
+      <ComputedProperty>
+        <Name>MyExtents</Name>
+        <Expression>SpatialExtents(Geometry)</Expression>
+      </ComputedProperty>
+    </ComputedProperties>
+  </AggregateQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicAllElements.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicAllElements.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicAllElements.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <FeatureQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <GeometryInfo>
+      <Geometry>Geometry</Geometry>
+      <GeometryTypes>7</GeometryTypes>
+      <SpatialContext>
+        <Name>Default</Name>
+        <Description>Spatial Context for Query Definition</Description>
+        <CoordinateSystemName>LL84</CoordinateSystemName>
+        <CoordinateSystemWkt>GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</CoordinateSystemWkt>
+        <ExtentType>Dynamic</ExtentType>
+        <Extent>
+          <LowerLeftCoordinate>
+            <X>-180</X>
+            <Y>-90</Y>
+          </LowerLeftCoordinate>
+          <UpperRightCoordinate>
+            <X>180</X>
+            <Y>90</Y>
+          </UpperRightCoordinate>
+        </Extent>
+        <XYTolerance>0.000001</XYTolerance>
+        <ZTolerance>0.000001</ZTolerance>
+      </SpatialContext>
+    </GeometryInfo>
+    <IdentityProperties>
+      <Property>SdfId</Property>
+    </IdentityProperties>
+    <FeatureClass>Default:ParcelFeatures</FeatureClass>
+    <Filter>ToInt32(SdfId) < 81</Filter>
+    <Properties>
+      <Property>SdfId</Property>
+      <Property>Geometry</Property>
+    </Properties>
+    <ComputedProperties>
+      <ComputedProperty>
+        <Name>MyCurrentDate</Name>
+        <Expression>CurrentDate()</Expression>
+      </ComputedProperty>
+    </ComputedProperties>
+    <OrderBy>
+      <Property>ID</Property>
+    </OrderBy>
+    <Ordering>Descending</Ordering>
+  </FeatureQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicBarebones.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicBarebones.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicBarebones.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <FeatureQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <FeatureClass>Default:ParcelFeatures</FeatureClass>
+  </FeatureQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicMinimal.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicMinimal.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicMinimal.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <FeatureQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <GeometryInfo>
+      <Geometry>Geometry</Geometry>
+      <GeometryTypes>7</GeometryTypes>
+      <SpatialContext>
+        <Name>QueryDefault</Name>
+        <Description>Spatial Context for Query Definition</Description>
+        <CoordinateSystemName>LL84</CoordinateSystemName>
+        <CoordinateSystemWkt>GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</CoordinateSystemWkt>
+        <ExtentType>Dynamic</ExtentType>
+        <Extent>
+          <LowerLeftCoordinate>
+            <X>-180</X>
+            <Y>-90</Y>
+          </LowerLeftCoordinate>
+          <UpperRightCoordinate>
+            <X>180</X>
+            <Y>90</Y>
+          </UpperRightCoordinate>
+        </Extent>
+        <XYTolerance>0.000001</XYTolerance>
+        <ZTolerance>0.000001</ZTolerance>
+      </SpatialContext>
+    </GeometryInfo>
+    <IdentityProperties>
+      <Property>SdfId</Property>
+    </IdentityProperties>
+    <FeatureClass>Default:ParcelFeatures</FeatureClass>
+  </FeatureQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicWithExplicitPropertyList.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicWithExplicitPropertyList.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicWithExplicitPropertyList.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <FeatureQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <GeometryInfo>
+      <Geometry>Geometry</Geometry>
+      <GeometryTypes>7</GeometryTypes>
+      <SpatialContext>
+        <Name>QueryDefault</Name>
+        <Description>Spatial Context for Query Definition</Description>
+        <CoordinateSystemName>LL84</CoordinateSystemName>
+        <CoordinateSystemWkt>GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</CoordinateSystemWkt>
+        <ExtentType>Dynamic</ExtentType>
+        <Extent>
+          <LowerLeftCoordinate>
+            <X>-180</X>
+            <Y>-90</Y>
+          </LowerLeftCoordinate>
+          <UpperRightCoordinate>
+            <X>180</X>
+            <Y>90</Y>
+          </UpperRightCoordinate>
+        </Extent>
+        <XYTolerance>0.000001</XYTolerance>
+        <ZTolerance>0.000001</ZTolerance>
+      </SpatialContext>
+    </GeometryInfo>
+    <IdentityProperties>
+      <Property>SdfId</Property>
+    </IdentityProperties>
+    <FeatureClass>Default:ParcelFeatures</FeatureClass>
+    <Filter>ToInt32(SdfId) < 81</Filter>
+    <Properties>
+      <Property>SdfId</Property>
+      <Property>ID</Property>
+      <Property>Geometry</Property>
+    </Properties>
+    <ComputedProperties>
+      <ComputedProperty>
+        <Name>MyCurrentDate</Name>
+        <Expression>CurrentDate()</Expression>
+      </ComputedProperty>
+      <ComputedProperty>
+        <Name>MyIDLength</Name>
+        <Expression>Length(ID)</Expression>
+      </ComputedProperty>
+    </ComputedProperties>
+  </FeatureQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicWithFilter.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicWithFilter.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_BasicWithFilter.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <FeatureQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <GeometryInfo>
+      <Geometry>Geometry</Geometry>
+      <GeometryTypes>7</GeometryTypes>
+      <SpatialContext>
+        <Name>Default</Name>
+        <Description>Spatial Context for Query Definition</Description>
+        <CoordinateSystemName>LL84</CoordinateSystemName>
+        <CoordinateSystemWkt>GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</CoordinateSystemWkt>
+        <ExtentType>Dynamic</ExtentType>
+        <Extent>
+          <LowerLeftCoordinate>
+            <X>-180</X>
+            <Y>-90</Y>
+          </LowerLeftCoordinate>
+          <UpperRightCoordinate>
+            <X>180</X>
+            <Y>90</Y>
+          </UpperRightCoordinate>
+        </Extent>
+        <XYTolerance>0.000001</XYTolerance>
+        <ZTolerance>0.000001</ZTolerance>
+      </SpatialContext>
+    </GeometryInfo>
+    <IdentityProperties>
+      <Property>SdfId</Property>
+    </IdentityProperties>
+    <FeatureClass>Default:ParcelFeatures</FeatureClass>
+    <Filter>ToInt32(SdfId) < 81</Filter>
+  </FeatureQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLAggregate.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLAggregate.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLAggregate.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <SQLQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <IdentityProperties>
+      <Property>RecordCount</Property>
+    </IdentityProperties>
+    <SQL>select count(*) as RecordCount from ParcelFeatures</SQL>
+  </SQLQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLBasic.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLBasic.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLBasic.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <SQLQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <GeometryInfo>
+      <Geometry>Geometry</Geometry>
+      <GeometryTypes>7</GeometryTypes>
+      <SpatialContext>
+        <Name>Default</Name>
+        <Description>Spatial Context for Query Definition</Description>
+        <CoordinateSystemName>LL84</CoordinateSystemName>
+        <CoordinateSystemWkt>GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</CoordinateSystemWkt>
+        <ExtentType>Dynamic</ExtentType>
+        <Extent>
+          <LowerLeftCoordinate>
+            <X>-180</X>
+            <Y>-90</Y>
+          </LowerLeftCoordinate>
+          <UpperRightCoordinate>
+            <X>180</X>
+            <Y>90</Y>
+          </UpperRightCoordinate>
+        </Extent>
+        <XYTolerance>0.000001</XYTolerance>
+        <ZTolerance>0.000001</ZTolerance>
+      </SpatialContext>
+    </GeometryInfo>
+    <IdentityProperties>
+      <Property>SdfId</Property>
+    </IdentityProperties>
+    <SQL>select * from ParcelFeatures</SQL>
+  </SQLQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLWhere.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLWhere.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLWhere.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <SQLQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <GeometryInfo>
+      <Geometry>Geometry</Geometry>
+      <GeometryTypes>7</GeometryTypes>
+      <SpatialContext>
+        <Name>QueryDefault</Name>
+        <Description>Spatial Context for Query Definition</Description>
+        <CoordinateSystemName>LL84</CoordinateSystemName>
+        <CoordinateSystemWkt>GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</CoordinateSystemWkt>
+        <ExtentType>Dynamic</ExtentType>
+        <Extent>
+          <LowerLeftCoordinate>
+            <X>-180</X>
+            <Y>-90</Y>
+          </LowerLeftCoordinate>
+          <UpperRightCoordinate>
+            <X>180</X>
+            <Y>90</Y>
+          </UpperRightCoordinate>
+        </Extent>
+        <XYTolerance>0.000001</XYTolerance>
+        <ZTolerance>0.000001</ZTolerance>
+      </SpatialContext>
+    </GeometryInfo>
+    <IdentityProperties>
+      <Property>SdfId</Property>
+    </IdentityProperties>
+    <SQL>select SdfId, Geometry, date('now') as current_date from ParcelFeatures WHERE toint32(SdfId) < 81</SQL>
+  </SQLQueryDefinition>
+</QueryDefinition>
\ No newline at end of file

Added: sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLWhereJoin.QueryDefinition
===================================================================
--- sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLWhereJoin.QueryDefinition	                        (rev 0)
+++ sandbox/jng/querydef/UnitTest/TestData/FeatureService/SQLite/UT_SQLWhereJoin.QueryDefinition	2013-04-30 15:21:47 UTC (rev 7465)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="QueryDefinition-2.6.0.xsd" version="2.6.0">
+  <SQLQueryDefinition>
+    <ResourceId>Library://UnitTests/Data/ParcelsJoinTestSQLite.FeatureSource</ResourceId>
+    <GeometryInfo>
+      <Geometry>Geometry</Geometry>
+      <GeometryTypes>7</GeometryTypes>
+      <SpatialContext>
+        <Name>Default</Name>
+        <Description>Spatial Context for Query Definition</Description>
+        <CoordinateSystemName>LL84</CoordinateSystemName>
+        <CoordinateSystemWkt>GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</CoordinateSystemWkt>
+        <ExtentType>Dynamic</ExtentType>
+        <Extent>
+          <LowerLeftCoordinate>
+            <X>-180</X>
+            <Y>-90</Y>
+          </LowerLeftCoordinate>
+          <UpperRightCoordinate>
+            <X>180</X>
+            <Y>90</Y>
+          </UpperRightCoordinate>
+        </Extent>
+        <XYTolerance>0.000001</XYTolerance>
+        <ZTolerance>0.000001</ZTolerance>
+      </SpatialContext>
+    </GeometryInfo>
+    <IdentityProperties>
+      <Property>SdfId</Property>
+    </IdentityProperties>
+    <SQL>select a.SdfId, a.Geometry, date('now') as current_date, b.NAME, b.RACRE, b.RBILAD, b.RTYPE
+from ParcelFeatures a 
+inner join Parcels b on a.ID = b.ID
+where toint32(a.SdfId) < 81</SQL>
+  </SQLQueryDefinition>
+</QueryDefinition>
\ No newline at end of file



More information about the mapguide-commits mailing list