开发者

I have an API that returns items, so do I need a Service / Repository, another layer of extraction

I have an API (a DLL) which has various methods that return objects / collections of items.

I would like to create a Web Service that would return items to the calling client.

So what's the best approach, call my methods directory on my API and that convert these into the DTOS using automapper and return them to the Web Service?

Internally my API uses a Service / Repository layer.

开发者_开发百科The information that is returned form my API isn't always in the correct format. So I would have to do some adjusting or write new methods.

So would the best idea be to have my own Service / Repository layer that would interrogate the database directory for my WCF Service rather than using the API.

Or use the API for most of the items i can and implement its own Service / repository for items that are not available from API.

I don't want to be duplicating my work, but I really don't see options.

Maybe the Service / Repository should be shared by my WCF and by my API?


It seems like the quickest way to implement it, while maintaining maintainable (say that quickly 3 times), is to use your API from within your service. So, your Web Service methods would call your API.

If what you return to the caller are serializable objects, and not EntityObjects (assuming Entity Framework), you don't need to map to DTOs. Just return the objects, and WCF will automagically return DTOs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜