0

What is the return value of the following code when the code failed to execute ?

_Dbcontext.Database.ExecuteSqlCommand("TRUNCATE TABLE [TableName]");

I know that the value on succeed will be -1 but still don't know what other values expected to return if anything goes wrong . The official documentation from Microsoft said the return value of ExecuteSqlCommand is the result returned by the database after executing the command but what are the returned values of the command TRUNCATE?

Heinzi
  • 167,459
  • 57
  • 363
  • 519
Cyber Progs
  • 3,656
  • 3
  • 30
  • 39

1 Answers1

4

I know that the value on succeed will be -1 but still don't know what other values expected to return if anything goes wrong.

TRUNCATE TABLE either (A) succeeds or (B) generates an error.

In .NET, this translates to (A) a return value of -1 or (B) an exception being thown. Since exceptions interrupt the control flow, there is no return value in the latter case.

Heinzi
  • 167,459
  • 57
  • 363
  • 519