简体   繁体   English

使用实体框架的ExecuteSqlCommand执行的TRUNCATE TABLE的可能返回值是什么?

[英]What are the possible return values of TRUNCATE TABLE executed with Entity Framework's ExecuteSqlCommand?

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 . 我知道成功的值将是-1但是仍然不知道如果出问题了,其他值会返回什么。 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 ? 微软的官方文档ExecuteSqlCommand的返回值是执行命令后数据库返回的结果,但是命令TRUNCATE的返回值是什么?

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. 我知道成功值将为-1,但仍然不知道如果出现任何错误,期望返回的其他值是什么。

TRUNCATE TABLE either (A) succeeds or (B) generates an error. TRUNCATE TABLE (A)成功或(B)生成错误。

In .NET, this translates to (A) a return value of -1 or (B) an exception being thown. 在.NET中,这将转换为(A)-1的返回值或(B)被抛出的异常。 Since exceptions interrupt the control flow, there is no return value in the latter case. 由于异常中断了控制流程,因此在后一种情况下没有返回值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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