1

I am learning asp.net MVC, as I have been using the sqlconnection, sqlcommands etc from my initial phases, I would like to initially start learning asp.net MVC without using the entity framework.

Can you give me a link or any idea of using the models to process data without using the entity framework.

1
  • The answers provide a good starting point. But don't forget to abstract away the points of data access. That way if you decide to use EF in the future you swap your ADO.NET implementations out. This will also help with testability. Commented Mar 17, 2011 at 4:02

1 Answer 1

2

So without entity framework you'll be using ADO.NET (See MSDN)

Those classes you mentioned SqlConnection, SqlCommand are part of the ADO.NET framework. The two Microsoft frameworks that build on this are Entity Framework and LinqToSQL.

If you don't want to us either you have to write you own models/classes, and then methods to persist those models into your database. (This is essentially what EF does) You won't get any LINQ or designers etc.

Also, ADO.NET does have a way to create strongly typed datasets. This might help a little.

What you are doing might help you understand whats going on under the covers, but do realize frameworks like Entity-Framework save a lot of time and effort by generating models for you.

Sign up to request clarification or add additional context in comments.

9 Comments

Hi giddy, thanks for your reply. Currently i am having my models with the sqlconnections and datasets etc.. I am returning the datarow objects from the model and getting them in the controller and passing them to the view and displaying data there. But what do i need is to know whether there is any way for me to pass datarow to a view like {return View(model.MovieDetails(id));}. If i send so, how can i receive the datarow in the view and display the data there.
ok. So depending on what version of asp.net you use, you can (1) define your model for the view as the type returned by model.MovieDetails(id) (Write @model <typename> for razor/cshtml or Inherits="ViewPage<Your type>") Then return View(modle...) should work.
(2) You can use ViewData or If you are on .net 4 you can use the C#4 dynamic keyword with ViewBag to pass any type from the controller to the view. See weblogs.asp.net/scottgu/archive/2007/12/06/…
@giddy Thanks for the links. I am using .net framework V4.0, VS2010 and MVC 2.0. Currently the ViewData works fine. But let me explore on the other options so that i can create a strongly typed views.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.