| ChrisRickard on May 13, 2011 at 10:25:24 PM (# 0) Speaking in generalities Entity Framework is rarely more efficient, processing wise. It saves developer time writing a DAL and getting strongly typed, fairly lightweight model classes instead of working with clunky datasets. The cost however comes from abstraction. EF tends to generate really bad SQL and object/relation mapping is actually really hard to do well in complex scenarios. Here is a really good (critical) article on the subject. All of which I've can relate to using EF and other ORM frameworks over the years.
However for something as simple as this you probably can get a slight boost out of EF as DataSets are a terribly inefficient in of themselves. I've never used EF and MySQL together but I know libraries exist for it. ChrisRickard on May 13, 2011 at 10:34:30 PM (# 1)And 2nd question: the DataAdapter looks at the RowState property of each DataRow. It will generate both an INSERT and an UPDATE statement if those states exist.
If you recreate the DataSet on every postback it will think every row is new. You would either need to re-query the database, find the row based on its PK and update it or fill out the datatable, call AcceptChanges, then modify each row to trick it into using an update instead of an insert. Or serialize the DataSet to ViewState or SessionState, both are equally horrific for performance. Monte on May 15, 2011 at 6:34:19 AM (# 2)Thanks for the replies, Chris!
With regard to #2, if I understand you correctly, I'd have to do something like this:
I would select a week from the week drop down (I have one, and since scores are put in weekly, well, I figured that would be a good way to go).
This would have an "autopostback" That would populate any data from that week into the appropriate row for the teams in the GridView. All that info would be in a DataSet, which I could (theoretically) put in a Session variable.
So then, let's say I only got half the scores put in for week 1, and now I'm entering the rest.
If I understand what you're saying, I can set it up to where the scores that are already present are "updated" (i.e. no row is inserted, but the values remain the same), but the new values are inserted.
Right? Monte on May 16, 2011 at 7:19:54 AM (# 3)Additionally, would it actually be more efficient to actually iterate through the recordset and do the insert/update one row at a time?
Although, I think I could see that adding a level of complexity I may not want to get into right now, since I would have to see if the data is already there. Although, if I query by the week first, I can compare. If there's a record in the dataset, then i'd do an update, if not, I'd do an insert. Although I'm not sure how that would work, if I run out of entries in the dataset before I get to the total number of rows in the gridview.
What about that? Annie Calvert on Jul 23, 2012 at 11:37:50 PM (# 4)Use data presentation method. It enables to implement the grid and tree list view in a single component. http://www.dapfor.com/en/net-suite/net-grid/tutorial
|