Creating Context object in Commerce Server 2007 site


hi,

currently working simple site want display series of catalogs commerce server 2007. face doubt on here. example,

where create catalogcontext, read examples forum blogs. saw few ways of achieving it. example codes are as below.

1. catalogcontext context = commercecontext.current.catalogsystem

2. catalogcontext context = catalogcontext .create(sitename)

out of 2 examples above, differences, not know first example is able to create context.

 

the reason why raise out question because doing testing on order system recently, use first method create ordercontext object , able add information inside database. wondering context object boundary. asi direct use commercecontext.current.ordersystem create ordercontext object without creating in first place. please correct me ask dumb question not know different between these two. please advise, .

 

this question gets asked lot developers work , 1 of important things understand when building highly-available commerce solution on top of commerce server 2007.

 

the first option correct way instantiate context objects *whenever possible*.  second option typically used when want hook commerce server outside of standard web context (ie: if want use commerce server apis winform app/batch processes/etc).

 

commercecontext.current singleton collection of resources initialized when web application starts (this occurs behind scenes because of of httpmodules commerce server sites have in web.config).  instantiating context on demand *very* costly, , if had create new context every time needed work system (instead of using pre-instantiated commercecontext.current object), application grind halt.

 

functionally, 2 contexts behave identically, , internally, system contexts within commercecontext.current being created using create(sitename) method within httpmodule.



Commerce Server  >  Commerce Server 2007



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'