Both the OrganizationServiceProxy and the OrganizationServiceContext support the dispose method. Do I need to wrap both of them in a using statement?
using (var proxy = GetOrganizationServiceProxy(Constants.OrgName))
{
using (var context = new OrganizationServiceContext(proxy))
{
// Linq Code Here
}
}
Or will disposing of the context close properly close the proxy, meaning only this is needed?
var proxy = GetOrganizationServiceProxy(Constants.OrgName)
using (var context = new OrganizationServiceContext(proxy))
{
// Linq Code Here
}
The context cannot dispose the proxy, as it cannot decide if it is used by any other object.
IF you look into
Disposeof OrganizationServiceContext, you’ll seebtw. you can combine both using statements