The data reader has more than one field. Multiple fields are invalid for primitive EDM types

I am trying to delete multiple rows from a table using the linq ExecuteStoreQuery method like this

  string query = "delete from IMPORTStatistics where districtid='" + districtId + "'"; db.ExecuteStoreQuery<int>(query); 

but he throws this exception

 "The data reader has more than one field. Multiple fields are not valid for EDM primitive types." 

What am I doing wrong?

For information only, I use MySql.

+6
source share
2 answers

Given that you execute the delete command (not the query), I think you should use ExecuteStoreCommand instead of ExecuteStoreQuery .

In addition, you should definitely use the parameters instead of entering the identifier directly into the command.

 string command = "delete from IMPORTStatistics where districtid={0}"; int rowsDeleted = db.ExecuteStoreCommand(command, districtId); 
+10
source

This is a really useful link after viewing. I found this

http://welcometoaspdotnet.blogspot.com/2012/08/execute-stored-procedure-with-entity.html

THX

0
source

All Articles