I have a bit of a problem, and I'm not really sure how to tackle it. I have my model assembly which contains about 200 different business objects (Order, Customer, Product, etc.).
I don't want to return an entire object graph when someone wants to get, for example, an Order. Instead I want to simply return the object and lazy-load (or even asynchronously load) the other parts. This seems like it's going to lead to a lot of "Get(Object Name)" services:
I don't want to create 200 different methods, one for each Get operation. I realize I could probably do something like: GetObject(string type, int id)
, and then use reflection somehow to get the appropriate object back, but I think that is even worse (possibly).
If I, instead, used T4 templates to automate the job of creating each of the different services, that would be better... but it still leaves me worrying about one thing... performance.
Is it bad to have 200+ different services being exposed (one for each object)?
WAS Hosting − Hosting a WCF service in Windows Activation Service (WAS) is most advantageous because of its features such as process recycling, idle time management, common configuration system, and support for HTTP, TCP, etc.
A windows service is what you need. WCF is a communications library, and unless you plan to communicate with your application via a client, you don't need it. Your problem is related to activation, and keeping your code active in the background is what windows services do.
With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.
Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.
From my experience, WCF + Entity Framework + Lazy loading + deep object graphs + performance requirements = big potential problems.
There is no amazing silver bullet that solves all problems, I ended up with the following:
private
. No more collection of objects automatically serialized to the client sideGetXXXX/GetXXXByYYY
methods. And even GetXXXByYYYWithZZZZWithWWWW
where ZZZZ
and WWWW
are names of eager loaded properties. Yes, there could be lots of methods, but you build them only when actually needed by the client side of the application, and you know what you are doing. This greatly helps to have good performances.Is it bad to have 200+ different services being exposed (one for each object)?
Those are 200+ different operations in a single service (I suppose). If your client actually needs to access to all your server-side entities, then yes, 200+ operations is OK, there is just no magic here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With