database - Create service to encapsulate business queries -
we have several (5+) applications hit same database , we're running issues applications take own hands build queries fetch same data. however, since different developers creating these queries they're not identical should be, returning different results time time.
as far can see there 2 possible solutions.
- create library each application references proper query
- create wcf service encapsulate common queries used each application , create client each application use
i'm leaning towards option 2 since give flexibility modify filters we're using in our queries, updating each application @ once.
the service hierarchy like
public class queryservice { private readonly irepository _repository; public queryservice(irepository repository) { _repository = repository; } public ienumerable<int> getcommonoperation() { return _repository.getcommonoperation(); } public ienumerable<anotherdto> anothercommonoperation() { return _repository.anothercommonoperation(); } }
then create client interact queryservice
.
so question general approach creating querying services sole goal of encapsulate commonly used queries/operations several applications?
you've answered own question. essentially, want seperate interface implementation, web service (or wcf) accomplish. if create assembly, you'll still need ensure assembly deployed seperate clients, or @ least in location accessible application utilizing it. seems lot more work. however, keep in mind, if make changes service signatures, client utilizing service have update reflect new definitions.
the great thing web service (wsdl) it's generic. can write client's in language can consume , parse wsdl -- unlike assembly, targeting specific build or os. whether have c#, java, ios, android, etc. clients, capible of utilizing services.
Comments
Post a Comment