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,
asked Nov 5, 2012 at 11:19
TheBoubou
20k54 gold badges153 silver badges251 bronze badges
2 Answers 2
Try this
context.Database.ExecuteSqlCommand
("DELETE [MYSCHEMA].TABLE1 Where TABLE2_Id = 5");
answered Nov 5, 2012 at 11:22
Asif Mushtaq
13.1k3 gold badges36 silver badges43 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Delete syntax is 'delete from TABLE where ...'
try context.Database.ExecuteSqlCommand("DELETE FROM [MYSCHEMA].TABLE1 Where Table2.Id = 5");
answered Nov 5, 2012 at 11:24
mcalex
6,7985 gold badges53 silver badges86 bronze badges
Comments
lang-cs