views:

113

answers:

3

We have this very strange issue on LINQ to SQL Code.

Consider this code snippet :

var wissen = db.Table.Where(f => f.Name == somevalue);
db.Table.DeleteAllOnSubmit(wissen);
db.SubmitChanges();

This works as expected on our dev servers, but when we are deploying this to our production server it doesn't give any errors but it doesn't delete anything neither altough it should.

When we replace this code with this :

db.ExecuteCommand("DELETE FROM Table WHERE Name = {0}", somevalue);

thing work just fine.

The workaround works just fine, but we would be happy to know what exactly goes wrong.

Looking forward to your comments :)

Dieter

+2  A: 

Have you tried to do a SQL Profiler trace on the production machine to find out which SQL is being emitted?

This should help you troubleshoot the issue.

Mark Seemann
+1  A: 

Is db a System.Data.Linq.DataContext? If not, try using one. If it is, call db.Log = Console.Out after instantiating, and it will send all the generated SQL to the Visual Studio output console. This should show what is going wrong.

If you can't run VS on the server, log output to a text file:

StreamWriter sw = new StreamWriter(pathToLogFile);
db.Log = sw;
// do your queries here
sw.Flush();
Dour High Arch
+1 log L2S output to a file
jeroenh
A: 

Yes db is a System.Data.Linq.DataContext.

The problem with debugging is that everything works just fine on the dev server, things get fucked up on the production server. Due to company policies we are not allowed to install VS on a production server.

If you have more information you should add it to your question, or leave a comment.
Dour High Arch