Stair structure
Hi all,
sometimes it's necessary to write a string over multiple lines like this:
string sql =
"select x, y, z " +
"from foo, bar " +
"where foo.name = 'something' " +
"and foo.id = bar.id "
After the final semicolon, I end up with that funny structure:
string sql =
"select x, y, z " +
"from foo, bar " +
"where foo.name = 'something' " +
"and foo.id = bar.id ";
Is there any way around this (indent only the first ine after the "="
sign), other than setting the "Continuous line indent multilier" to zero?
Thanks,
-Michael
Please sign in to leave a comment.
Have you tried using the @ string literal version without the string
concatenation? I suppose it's kind of a hit-and-miss alternative since some
people like it and others don't:
string sql = @"
select x, y, z
from foo, bar
where foo.name = 'something'
and foo.id = bar.id";
"Michael Winter" <delphi.net@gmx.net> wrote in message
news:fq3euf$r0t$1@is.intellij.net...
>
>
>
>
>
>
>
Lothan schrieb:
Sure, that works, but that's not what I want since it includes line
breaks and lots of spaces in the resulting string.
Thanks anyway.
-Michael
Lots of line breaks and spacing will not bother SQL statements and will actually make them much easier to read in error messages and SQL profiler. I use @"" for my SQL with tons of line breaks and spacing.
HTH,
Sam
Which version of R# are you using? I'm using VS 2005 with R# 3.1.584.3 and
it formats the code just fine when I type the last semicolon (as in your
first example).
My Continuous line indent multiplier is set to 1, I'm not sure which other
settings affects this.
"Michael Winter" <delphi.net@gmx.net> wrote in message
news:fq3euf$r0t$1@is.intellij.net...
>
>
>
>
>
>
>
Dag Christensen schrieb:
Thanks for the hint. I'm using VS2008 and R#4.0.738.4 but that's not a
specific R#4 issue. A teammate just tried with exactly the same setup as
you have, and the same happened as with my one.
He found that the solution is to set "Other/Align Multiline
Constructs/Expression" to true.
So - problem solved. And just if he reads this: ?akujeme ?uboš.
-Michael
Agreed... I typically use this syntax with all embedded SQL queries because
it makes it so much easier to copy and paste between Visual Studio and SQL
Server Management Studio. I generally create the queries in SQL Server
Management Studio, fine tune them until the query plans are acceptable, then
paste them into the code.
"Samuel Neff" <no_replay@jetbrains.com> wrote in message
news:8003206.1204218504304.JavaMail.itn@is.intellij.net...
>
>