我刚刚开始使用 web.api 为我们现有的 asp.net mvc web 应用程序的移动版本公开数据的 WCF 服务项目。
到目前为止,我已经使用这个WCF web.api 入门教程来运行一些东西,并在 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 应用程序,如何才能最好地使用现有的服务层和域模型,或者最好不要这样做?分开服务更好吗?
任何人都可以为我指出一些好的初学者教程吗?
谢谢,凯