-1

I am studying ASP.net MVC Framework.
After I reading this article, I can list all data to View via my database.

Then l like Repository pattern which is not too difficult to study according to that article.
But what I really would like to do is I want to insert data to database via my View.

So I am searching for a way how to do by using ASP Net MVC , Linq to sql and Repository pattern.

So, Could anyone please give me any suggestion or references to learn?

Frank Myat Thu
  • 4,448
  • 9
  • 67
  • 113

2 Answers2

1

See http://www.asp.net/mvc.

Also take a look at full apps like the music store and nerd dinner.

If you have the latest asp.net-mvc3, when you add a new controller you have a templating feature that will write some basic CRUD code based on an Entity Framework model.

enter image description here

Try it and have a look at the code, its an excellent example.

gideon
  • 19,329
  • 11
  • 72
  • 113
  • thank @gideon, i appreciate your help. I want to use LINQ to SQL Repository pattern rather than entity framework which i think a little more complex. – Frank Myat Thu Dec 26 '11 at 06:35
  • 1
    @Frank Linq2Sql and linq2entities have a lot of overlap and the example should be helpful to understand how to stitch the DB code together. The repository pattern is an abstraction and should apply to any framework you use, even NHinbernate. See this answer : http://stackoverflow.com/a/4583099/368070 – gideon Dec 26 '11 at 06:39
1

Happy learning Frank!! here is one for you. Option 1:

http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part1-cs

they have C# and VB examples. If you encounter any entity framework related errors, then install "SSCERuntime_x86-ENU" for windows 7 then try again. Worked for me. Should work for you as well. You can get it in microsoft downloads.

So, the above one talks about the movies database.

Option 2:

Step 1: Go with option 1, Instead of keeping the web.config as they say, you can modify it with your local Movies database you create.

Step 2: Right click project add an Entity data model referencing the database you created and add Movies table

Build the solution

Step 3: Right click controller --> Add new controller -> From entity framework --> Specify the classes you have created in "Models" folder. This will then create CRUD code for you.

There you go...

In option 1, you may not have seen the table, but in Option 2, You design your own table and play with it.

CodeMad
  • 950
  • 2
  • 12
  • 30