Contents

46 Articles
6 Comments

Search

#3 − Comments received via mail from Sergio Rosas

Marco

We received this interesting update/information from Sergio Rosas via mail.

About deleting multiple elements at the same time. It’s quite old by now but I wanted to point out some things.

In the post, the author says the best way to delete several rows in one is to use a foreach loop, as the SqlQuery method doesn’t allow to execute a DELETE statement.

Well, I recently found myself in a similar situation, where I needed to update / insert data into the database through a stored procedure. This procedure doesn’t return any data, so the SqlQuery didn’t work for me. Instead I found that the ExecuteSqlCommand method works perfectly fine for this kind of situation, so you could do the DELETE command with this one.

There’s another thing about EF. You can do (using the same examples as the post):

context.Users.RemoveRange(context.Users.Where(u => u.Name == "John"));

but you still will get a SELECT to retrieve the data and then you will get a DELETE statement for every row that matches the condition. This happens, as far as I know, for every batch delete, update or insert operation in EF 6 or lower. It’s intended to be fixed in the EF 7 release.

#2 − Thanks for the clarification!

Marco

That ExecuteSqlCommand uses SQL rather than ESQL makes me want to use it even less, though.

I’m using an ORM—and a code-first ORM, at that—because I don’t want to write SQL and I certainly don’t want to write SQL that will break if I rename/remove a table or field. That way is fraught with frailty, I think.

Anyway, thanks for the feedback! It’s good, of course, that EF has ExecuteSqlCommand, to be used in a pinch.

#1 − Two clarifications

anon@reverse.completel.net
  1. The ExecuteSqlCommand method would probably do what you want. That is: context.Database.ExecuteSqlCommand(“DELETE FROM Users WHERE Name = @name”, new SqlParameter(“name”, “John”));
  2. The SqlQuery and ExecuteSqlCommand do not use ESQL, but raw, database SQL. (As the usage of the SQL Server specific “SqlParameter” instead of the EF’s “ObjectParameter” hints at);

#3

Marc

Mit Mono und Apache hatten wir bis jetzt keine produktiven Projekte. Usere Erfahrungen mit ASP.Net MVC auf Mono konzentrieren sich aktuell auf embedded Linux mit Mono 2 und dem in C# geschriebenen XSP-Webserver. Apache wäre uns viel zu gross gewesen mit Total 200 MB Memory und 250 MB HD. Insofern können wir hier keine Aussage zu Performance-Vergleiche machen, sorry.

(Attached to Article ASP.Net MVC 3 auf Mono/Linux)

#1 − Daten für Performance

anon@mx.fidor.de

Da die Migration von ASP IIS auf Mono/Apache immer wieder ein Thema ist (insb. auf Grund der raketenartig ansteigenden Lizenzkosten seitens MS), woltle ich mal fragen, ob irgendjemand verlässliche Vergleichsdaten für die Unterschiede in der Laufzeit hat/kennt?
In den Anfangstagen war die Mono-Implementation deutlich langsamer; da das jetzt aber schon einige Jahre her ist, habe ich Hoffnung, dass die Performance irgendwann mal vergleichbar sein sollte?
.NET aufzugeben wäre schade, aber MS muss auch klar sein, dass die Kunden nur eine gewisse Preistoleranz haben ;-)

Grüße,
Flo
http://www.lelala.at | Lelala

(Attached to Article ASP.Net MVC 3 auf Mono/Linux)

#1 − GOOO

anon@DSL-mum-Static-ILP-193.123.170.122.airtelbroa