Dynamicweb.Ecommerce.Orders.Order.GetOrders("SELECT * FROM EcomOrders Where OrderCart = 'False' AND OrderStateId not in ('OS9','OS3','OS4') AND OrderTransactionStatus = 'Succeeded'")
Gives a null reference with below stacktrace, the sql works fine when used in SQL server management
System.NullReferenceException: Object reference not set to an instance of an object.
at Dynamicweb.Ecommerce.Common.Context.GetCurrency()
at Dynamicweb.Ecommerce.Prices.PriceInfo..ctor()
at Dynamicweb.Ecommerce.Orders.Order..ctor(IDataReader dataReader)
at Dynamicweb.Ecommerce.Orders.OrderCollection.Load(String sql)
at Dynamicweb.Ecommerce.Orders.Order.GetOrderCollection(String query)
at Dynamicweb.Ecommerce.Orders.Order.GetOrders(String query, Boolean preLoadOrderLines)
at Pilgrim.Website.CustomModules.Helpers.OrderTransfer.ExportAllOrders()