简体   繁体   中英

Delete multiple rows with Entity Framework 5

I tried this piece of code :

context.Database.ExecuteSqlCommand
("DELETE [MYSCHEMA].TABLE1 Where TABLE2.Id = 5");

But I get this exception : Cannot call methods on nvarchar.

Currently I use a loop but I'd like avoid this.

Thanks,

Try this

context.Database.ExecuteSqlCommand
     ("DELETE [MYSCHEMA].TABLE1 Where TABLE2_Id = 5");

Delete syntax is 'delete from TABLE where ...'

try context.Database.ExecuteSqlCommand("DELETE FROM [MYSCHEMA].TABLE1 Where Table2.Id = 5");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM