Simple ASP.NET MVC example
i need some advice on building a real environment MVC project.
I already went thru all the tutorials in asp.net. But i found that most of the tutorials are using ninject, Entity Framework(EF) or linq to sql(L2S)... But i do not want to use 3rd party solution or some others "new" language.
My requirements:
i want to connect DB using connectionstrings :
<connectionStrings> <add name="SQLConn" connectionString="Data Source=MyPC\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>
A CRUD page which grab from Database using the above connectionstring(SQLConn), with a listing page, update, delete and create new record page + validation at Model.
开发者_开发问答I prefer to have a raw repository pattern, instead of using EF, L2S or some others "extra" tools. i want to use "SELECT * FROM tblTest...".
i do not want to include SQL query everywhere on my page, i prefer include all of them in Model.
My problems:
public SqlConnection conn = new SqlConnection("SQLConn");
This method seems only working in webform pattern, may be i make a mistake.- How to develop in Repository pattern with Model validation?
I just need some ideas how to make all these link up together. With the List page as example is good enough. or any sites/blogs for me to refer? Example with MVC 3 is fine too.
Thanks.
Jason
In CustomerDAL
class, you can direclty use SqlConnection
instead of Linq2Sql
精彩评论