Over the course of several months, I posted several questions about the structure of ASP.NET and Database-Abstraction-Layers applications in order to rewrite (from scratch) an outdated web application. I recently stumbled upon MVC3 / Entity-Code-First and, after spending some time with him, fell in love with how it works, how everything is abstracted, and I'm looking for any excuses for using it!
A legacy application is a Windows C ++ / CLI service that generates its own HTML code (very old HTML code with CSS, which is used only for colors and tables) and the interface is very closely related to business logic. In principle, everything will be an improvement.
However, perhaps this is due to the fact that I have not spent enough time with MVC, I had some doubtful doubts, and wondered if some of you MVC-Pros could develop their experience in my area.
The legacy application uses custom controls (its own form) to bind combined fields to data and dynamically re-populate dependent combined fields based on a choice in another. In ASP.NET, this question is easy to answer, because the asp:DataList control simply bounces on the page, binds it to the data source and voila. A little simple code then allows you to filter other combined fields by the selected value. It would also be easy in ASP.NET to implement another list of data that even automated the dependent data in this way (which would mimic the behavior of an outdated application well). I can't seem to find the concept of user controls in MVC, although I assume that this material is handled by jQuery calls to get the data and throw it into the combo box. But is this done for every combo box on every page that has one? Is this the case for partial views with the appropriate parameters passed in, or is it just plain stupid?
I assume this has more to do with Entity Framework than with MVC, but most of the examples I found on the Internet and tutorials do LINQ queries to return a collection of objects to display, for example, from the MvcMovie example:
public ActionResult Index() { var movies = from m in db.Movies where m.ReleaseDate > new DateTime(1984, 6, 1) select m; return View(movies.ToList()); }
which is then displayed using the @foreach loop in the view. It's great. The legacy application has one view page, which is used by all other areas of the system (there are more than 50). He does this by checking the order of the columns defined for the user logging in, smoothing out any foreign keys (so that a field is displayed on the external table as opposed to a value that is not user friendly), and also allows the user to apply custom filters for any column. He does this also for tables that have more than 100 thousand rows. How could you write something like this using Entity-framework and views? In ASP.NET, I would probably solve this by dynamically generating some kind of grid view and automatically generating columns and applying filters. It seems to me that I can work more in MVC. Am I missing something?
A legacy application has several operations that work with large data sets. Now, since it was a service, he could run these threads without worrying about being disconnected. One of my questions here regarding SO was about static managers and implementing the AppPool utility, but I decided that having a helper service was a good option. However, the legacy application applies the update statement to large groups of records, rather than single lines. Is this possible with Entity-Framework without writing custom SQL in a database that bypasses regular models? Hope I don't need to do something like this (not what I would like, this is just an example)
var records = from rec in myTable where someField = someValue select rec; foreach(rec in records) rec.applyCalculation(); db.SaveDbChanges();
I suspect this may take a long time, while an outdated application will simply do:
UPDATE myTable SET field1 = calc WHERE someField = someValue
Therefore, it is not entirely clear to me how we use our models in this way.
The legacy application has some data panels in the layout, which are transferred to any page on which you are located. Looking at Stackoverflow here, I found this question, which implies that each view should pass this information to the layout? Is this true, or is there a better way? Ideally, I would like my layout to be able to access a specific model / repository and display data in the sidebar. Adding to each page view can be quite repetitive and error prone. Not to mention the time it takes if I need to change something. This will be a partial view, but again I'm not sure how to pass the model to it on the layout page.
Finally, I was disappointed after setting Ef-Code-First to find that a really good attribute, SourceName hadn't done it yet. This would be very good when comparing against legacy tables / columns, and I'm not quite sure why this was out of the question at this point (at least my intellisense says it isn't!) Did anyone understand when this could happen? I could do without him for a while, but in the end it would be incredibly useful.
Sorry for the long questions. After centuries of investigative work in ASP.NET and MVC3, I really want to go with MVC3!
Moo juice
source share