我刚刚开始使用web.api开发一个WCF服务项目,以便为我们现有的asp.net mvc web应用程序的移动版本提供数据。WCF Web服务和从数据库检索 - 使用现有的asp.net服务层?
到目前为止,我已使用此WCF web.api getting started tutorial得到一些东西在运行,在ServiceContract中创建假数据。
服务合同是这样的:
[WebGet(UriTemplate = "")]
public IQueryable<Workspace> Get()
{
//I want to use our existing service layer like this:
//WorkspaceService service = new WorkspaceService();
//service.ReturnAllWorkspacesByUsername("mary");
//this is fake data for testing
var workspaces = new List<Workspace>()
{
new Workspace() {Id = new Guid(), Title = "Implement WCF Web Services"},
new Workspace() {Id = new Guid(), Title = "Add APIs to WebService"},
new Workspace() {Id = new Guid(), Title = "Map Routes"},
new Workspace() {Id = new Guid(), Title = "Expose Resources"},
};
return workspaces.AsQueryable();
}
我想用现有的MVC应用程序尽可能,我该如何使用现有的服务层和领域模型最好的,或者是它的最佳实践不是?将服务分开更好吗?
有人可以指向我一些很好的初学者教程吗?
感谢, 凯
谢谢:)我很欣赏回复。我想我会尽可能地使用现有的服务层,并对DTO进行一点或研究。 – Kai