1

Background

I've been killing some neurons lately with this. I would like to make a multi-tier application for parcel services like UPS and such. Long story short, the backend will be a WCF-based server while the consumer will be an ASP.NET MVC application. The idea is that the backend will handle all business operations (like adding a new shipment, editing existing shipments, carriers and such) but will provide the consumer with data in form or queries.

And the Issue Is...?

My plan for business operations is that the consumer should pass all the information required to complete the operation (pretty much like a model, i.e. for adding shipments, the consumer would send all the required information for those shipments.) Now, my actual issue is with data querying.

The consumer application should be able to display the backend-provided data in anyway it desires, not limited by a DTO. For example, when listing shipments, I only want to show a grid with Name, ID, date shipped and such, not the entire shipment object graph.

How can the consumer application specify the data projection it needs to the WCF endpoint?

Options

I thought on creating several operation method overloads exposing different DTOs for different purposes. I.e.:

IList<ShipmentDetailsDTO> GetAllShipmentsAsDetailed(); 

IList<ShipmentListingItemDTO> GetAllShipmentsAsListingItems();

I dropped the idea since the backend is adapting to the consumer application needs, and this is not a good practice. The backend should be agnostic of the consumer.

Another option is to combine WCF data services for querying data and WCF regular services for business operations. This way the MVC application can project the data like a regular LINQ query against the WCF data services. Sounds quite elegant but I would like to hear a second opinion.

Any thoughts? What would you do if you were me? I need an elegant and practical solution for this.

4

0 に答える 0