Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MVC - Question about Url.Action() and advanced EF Model.

Status
Not open for further replies.

fletchsod

Programmer
Dec 16, 2002
181
I have 2 questions...


1) I noticed this "Url.Action(...)" doesn't seem to support the "Area" value other than "Controller" & "Action" value. So, how do I make it support the "Area" value?

--snip--
Url.Action("Login", "Member", null, "http", Request.ServerVariables["HTTP_HOST"])
--snip--

2) Now that I have some understanding of EF models. Is there a good detail article/tutorial on using it for detail programming? The have a movie clip that shows some basic HOW-TO, nothing deep. I wanna know how to use stored-procedure, how to use table joins, how to use common-table-expression, list, etc...

Thanks...
 
I'm not familiar enough with MS MVC (I use Monorail) but I don't believe you navigate directly to an area. An area is a subset of markup you can share between views (similar to a web user control in webforms). Conceptually it doesn't make sense to navigate to a area, you would navigate to a controller that renders a view. that view would contain the area. That's my understanding at least.

In reference to EF. EF solves the problem of mapping a domain model to a relational model. MVC solves the problem of processing URL requests and returning a result (typically html) to the user. the two can be used together, but it doesn't change how you use it. the concepts of EF would not change for a fat client, or service bus scenario.

EF itself is an ORM. the idea is that your code focuses on the domain model and EF manages how the changes in your domain model are persisted back to the database stored procs, table join, etc don't matter. you would query the domain model through the EF DataContext.

I use NH which is another ORM. the details are different but the concepts are the same. for example with NH I would get a father and his children with the following query
Code:
var father = session
   .QueryOver<Father>(id)
   .Include(father=>father.Kids)
   .UnqiueResult<Father>();
which would roughly translate to the following sql
Code:
select f.*, k.* from father f left join kid k on f.id = k.father_id where f.id = @id
Not having used EF I don't know the exact details, but I would imagine it would look something like that.

the point is that I'm working with the domain model, not the database model. Most of the time there is a direct 1:1 coloration between the domain model and the database schema, but it doesn't have to be that way. at least not with NH.

It may be helpful to study the technologies independently. create an MVC project without a database, create objects in memory and render the views.
Then study EF, create a domain model, generate the database and execute various queries and commands to see how EF behaves. then combine the two so you have a web application accessing a database.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
I have noticed everyone have their own preferences on ORM, EF & database (ADO.NET Entity, NH, etc.) I also noticed there are several or many more different models to use. So, that is not very helping. :-/

I'm using MVC3 (Razor) now and EF 4. I have read that EF had improved alot now but still is an on-going process on improvement. I have found that validation model don't work for me as it's not flexible enough (or modified), so I wrote the custom validation in controller so it can trigger the JQuery to do the animation error. (Website doesn't need to look like HTML 1.0 this way). I prefer the Database-First over the Code-First model so I don't lose the database. I have found the domain model suit my need due to a large website which is another project I'll be working on next month. (For now, just finish this one basic website project & have it go live, to show what I've learn from MVC and EF). I'm in the process of figuring out how to properly use EF in domain model. I read some articles that domain model is not the way to go. Oh well.

I bought 2 books over the weekend recently, unfortunately they don't say much about EF or LINQ-To-Entity languages. So, I'm gonna have to look around for a book on LINQ-TO-Entity query. Because last friday, I spend 10 hours figuring out how to use LINQ-TO-Entity to update 1 row of data, due to incomplete article/documentation on how to use it from the Internet. :-/

It gonna be research, trial & error and learn from it. It is too bad nobody really write a book about LINQ-To-Entity for EF 4.

Alright, thanks...
 
There are 2 things to consider.
1. the concepts
2. the syntax

the concepts are universal, no matter what ORM or OOP language you use. If you understand the concepts then it's just a matter of syntax. That's the easy part.

I would start with the concepts of domain models and ORMs. 2 books with cover the subject are Domain Driven Design and Patterns of Enterprise Application Architecture. the Patterns book also cover MVC & MVP which is a plus in your situation. These books are conceptual in nature. example code will be in java, but it's the concepts they are demonstrating that are important.

all the other cruft of [tt]this vs. that[/tt] is just a personal development preference. each framework will solve the problem differently with the same end goal in mind. The key is finding the tool(s) which allow you to be most productive.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top