0

I'm new in Asp.net MVC pattern. I used to develop website using asp.net web forms. I did research for hours about MVC and got a little understanding. But there're still some problems that keep confusing me.

(I decided to use Code First)

I have to display some pretty complex data, for my old project, i was using Stored Procedure, now i think i'm gonna change to LINQ, the questions are :

  • Does it affect the performance ? I was having good performance with SP.
  • How do i "define" the objects created by the query (in this case is the result set), should i define it in model classes ?

To be more specific, this is how i get things done in my old project, i have a class called ReportData (please note this is a mini-version, the actual class contains more properties) :

public class ReportData 
{
public string CityID { set; get; }
public DateTime ResultDate { set; get; }
/// ... 
// free fields
public int INT1 { set; get; }
public int INT2 { set; get; }
public int INT3 { set; get; }
public int INT4 { set; get; }

public string STR1{ set; get; }
public string STR2 { set; get; }
public string STR3 { set; get; }
public string STR4 { set; get; }
}

And everytime a Stored Procedure is executed, i put the result into this class, and build the HTML markup from this class :

foreach (ReportData r in listReportData)
{
// build html markup here     
}

This way i can save a whole lot of works, i don't have to write code twice for any "same same" results. And it's running ok, but i have to change due to some circumstances.

Now when stepping into MVC world, i found it very confused and honestly i'm now lost with the controlers, models, and views stuffs.

I also read about some related topic which pops up when i was typing this question, but they seem doesn't help me much in my case, oh i'm too nerd to understand the answers!

NeedAnswers
  • 1,411
  • 3
  • 19
  • 43
  • 1
    If you already have stored procedures why go `code first` ? Use your existing database and inform yourself about `database first` oder `model first` approaches. You don't need to reinvent the wheel. You can also use your already defined SP's with Entity Framework; see http://stackoverflow.com/questions/20970416/using-stored-procedure-in-entity-framework and google.com for reference. Otherwise you don't seem to understand asp.net mvc,s o this is the wrong place to ask this question. We are here to solve concrete programming questions. Not write a How-To. – Marco Jun 21 '14 at 09:24
  • Actually my current website is using Database First approach. Assuming i want to get rid of all the stored procedures and using LINQ approach. What do you suggest then ? – NeedAnswers Jun 21 '14 at 09:38

0 Answers0