I have a class which does stuffs with database, I want it to be used in these two ways:
1: a dll which can be referenced and used locally with direct call.
2: can be hosted as a WCF service.
when it is hosted as a WCF service many clients can connect to it but when it is used as a dll it just has one client.
how should I design my class?
For example I want to use it like this in dll form:
var a = new A();
and then call a.DoSomething()
or host it in WCF service and call server.DoSomething() from my client.
put your class into an assembly of it’s own along with any support classes it needs and just reference that assembly from your WCF service.
Put your “api” in an interface, implement it fully in your “work” assembly, then implement it in your WCF service, but just haave that act as a proxy. Using an interface will mean you don’t miss anything in your proxy.