Question

(This relates to Microsoft's SitkaSoapService, in the service reference at https://database.windows.net/soap/v1/)

I'm using SitkaSoapServiceClient to access my SQL Data Services database by SOAP.

Should I use a "using" statement every time I use this proxy class? Or does it do its own connection handling in a safe way internally?

I.e. do I need to say:

using (SitkaSoapServiceClient proxy = GetProxy())
    proxy.Update(scope, entity);

... or is it safe to say:

GetProxy().Update(scope, entity);

[where GetProxy() returns a SitkaSoapServiceClient object.]

Was it helpful?

Solution

Does the proxy class code compile when wrapped in a using statement? If so, it implements IDisposable and I'd use it.

EDIT: calling Dispose() should incur little overhead if it does nothing, and if the designer of the class decides at a later date to allocate unmanaged resources you will be protected from a leak.

OTHER TIPS

You should always use using when the class implements IDisposable, because the author of the class tells you that it contains some resources that should be freed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top