忽略 TSQL 的仇恨者;了解一些 TSQL 本质上没有错!无论如何,我会通过(如果我保持你的格式,这不是我的标准 - 但是......嗯);
// your existing code at, say, this level
var query = @"
select top 1
u.UserID
from
dbo.Users u
where
u.SystemUser = 1
and u.Status = @Status";
// some more code at, say, this level
通过将 TSQL 保持在左侧,任何缩进等都更容易在 IDE 中完成,但它也使 TSQL 更短,并且在查看跟踪时更容易调试,因为它不是奇怪的 30 左右的字符. 在 the 之前换行select
也有助于保持整洁。
Personally, I also find the disjoint between the code indent and the TSQL indent helps find TSQL - and TSQL is pretty important to me, so this is a good thing. And emphasising that we've just switched "world" (for want of a better term) is not harmful, either.