When to use commerce query ?-Collection of common programming errors

Kumudha.D-

Here’s the MSDN link for the CommerceQuery object http://msdn.microsoft.com/en-us/library/dd327963(CS.90).aspx

These objects are the suggested mechanism for working with all the Commerce Server 2009 systems in a runtime scenario[1]- effectively all profile, catalog, marketing, and order information should be retrieved and/or updated on your site using the CommerceQuery object.

If you’re developing an ASP.Net application, I would actually recommend that you leverage the Microsoft.Commerce.Portal.Common assembly and work with the various “Controller” and “Utility” classes in that assembly (CatalogController, CatalogUtility, for example), as these classes already encapsulate the required CommerceQuery objects, and are somewhat more intuitive to work with[2].

The “OrdersWebService” that you refer to is intended as an administrative API and uses the objects from CS2007- you cannot use CommerceQuery objects to work with this system- if you’d like to work with a wrapper for this API, consider using the OrderServiceAgent and OrderManagementContext objects from the CS2007 API stack (http://msdn.microsoft.com/en-us/library/microsoft.commerceserver.orders.ordermanagementcontext(v=CS.90).aspx and http://msdn.microsoft.com/en-us/library/microsoft.commerceserver.orders.orderserviceagent(CS.90).aspx).  It should be noted that these objects are intended for administrative purposes only, and should not be used on a runtime site without very careful design considerations; misuse of these objects can create rather serious security and performance issues down the road.

[1] By runtime, I’m referring to a public (or semi-public) e-Commerce application which serves a large user-base and is highly available.  This should be distinguished from Administraiton scenarios which serve a smaller user base and do not require triple-9 availability.

[2] There are always exceptions to this, but these classes should be flexible enough to handle *most* of your functional requirements.