开发者

ASP.NET MVC Database connectivity using ADO.NET

开发者 https://www.devze.com 2023-04-12 23:43 出处:网络
I\'m new to ASP.NET MVC. I want to work with SQL Server database with stored procedures without using LINQ but standard ADO.NET. How can I do that? Is there any useful开发者_JAVA技巧 video tutorial or

I'm new to ASP.NET MVC. I want to work with SQL Server database with stored procedures without using LINQ but standard ADO.NET. How can I do that? Is there any useful开发者_JAVA技巧 video tutorial or example for that?


I'd consider looking at Rob Conery's tutorial videos at tekpub.com This is a good place to learn ASP.NET MVC

A good pattern to use is the repository pattern with Inversion of Control. If you decide to change your data access method in future it makes things a lot easier. You can call your stored procedures and do your mapping to your business objects in the repository layer then you can pass these back to either a service layer or the controller depending on how big your project is going to be.

A Service layer is beneficial for larger scale projects as you can keep the controllers tidy by refactoring code into the service layer.

So project organisation wise you could go with something like this...

ProjectName.Web -- Controllers / Views / ViewModels
ProjectName.BusinessObjects -- Your Poco's for passing between all layers
ProjectName.BusinessLogic -- Service Layer / Repository Layer

You could have a data access layer also where you could implement an Object Relational Mapper for mapping data from the database without having to do all the data access coding long hand. A good choice here would be something like Dapper or PetaPoco

ProjectName.Data.Dapper
0

精彩评论

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

关注公众号