We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this questionI have to build a web application on asp.net MVC that have a data service reference WCF as DB. I have no idea on how data pe开发者_开发知识库rsistence work on asp.net. There are resource on this arguments?
I would recommend you Pro ASP.NET MVC Framework which is an excellent book about ASP.NET MVC in general. It doesn't specifically treat WCF but once you understand the concept of abstracting your data access layer into a repository inside your ASP.NET MVC application it doesn't really matter where does the data comes from. It could be a SQL database, a XML file, a WCF service, ...
The next part would be to write the WCF service. This step could be done independently from the client application. Once the service is exposed you would generate a client proxy from the WSDL by using the Add Service Reference...
dialog in Visual Studio and you would be ready to call it. There's nothing specific in ASP.NET MVC for consuming a web service, it would be the same as any other type of application: console, windows, web, ...
WCF on the .NET Stack is very simple, after you add a Service Reference, you simply write code like this:
var proxy = new WcfServiceClient();
var myData = proxy.ReadData();
//...
myData.Name = String.Format("{0} {1} {2}", prefix, first, last); // I know, data denormalization, so shoot me...
proxy.UpdateData(myData);
In terms of where you put this code in an ASP.NET MVC application, you'll need to investigate the basics of writing a MVC app; that code would likely live in the Update
method of your myDataController class.
I can recommend this book for learning ASP.NET MVC. The focus is on Linq-To-SQL -- but you should be able to substitute in your WCF Services where necessary.
精彩评论