C#中的长插入查询 [英] Long insert query in C#

查看:59
本文介绍了C#中的长插入查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的查询时间很长,无法看到语句中要插入的内容,因此我想在下面提到的两行或三行中将此查询简化:

I have long query and not able to see what I am inserting in the statement and I want to saprate this query in in 2 or three lines mentioned below:

SELECT DocTemplate.DocTId, DocTemplate.DocTitle AS DocTitle, DocTemplate.TemplateAttachment AS TemplateAttachment, DocTemplate.PostDate AS PostDate, UserDocDefault.UserId, UserDocDefault.DateTo As DateTo, UserDocDefault.DateTill As DateTill 
FROM DocTemplate 
INNER JOIN UserDocDefault ON DocTemplate.DocTId = UserDocDefault.DocTId 
WHERE (UserDocDefault.UserId = 11003)


void Page_Load(对象发送者,System.EventArgs e)

非常感谢.

VIjay


void Page_Load(object sender, System.EventArgs e)

Thank you very much.

VIjay

推荐答案

奇怪!即使时间很长,又有什么问题呢? QuickView或

1.将其分配给字符串
2.放置断点后的字符串定义
3.将鼠标悬停在字符串变量上
4.将会出现一个带有下拉菜单的搜索图标(两者都很小)
5.单击下拉列表,然后选择文本Vizualizer"
6.分配给字符串的整个查询将在一个对话框中打开,在该对话框中可以正确查看它.
7.如果需要,甚至复制它

顺便说一句,您的查询不是那么大,任何人都会感到困惑.还有更大的.


另外,如ryanb31在注释中已经建议的那样,将整个查询分为多个字符串,然后在末尾使用String Builder附加它们以供使用.

Strange! What''s the issue even if it is long? QuickView or

1. Assign it to string
2. Put a breakpoint post string definition
3. Hover your mouse over string variable
4. There will be a search icon with a dropdown (both very small)
5. Click on dropdown and select ''Text Vizualizer''
6. Whole query assigned to string would open up in a dialog where it can be viewed properly.
7. If needed, even copy it

BTW, your query is not that big that confuses anyone. There are much bigger ones.


Alternatively, as ryanb31 already suggest in comments, break the whole query into multiple strings and then append them using String Builder at the end to use.
Have
string selectPart = "......";
string fromPart ="...";
string joinPart = "...";
string wherePart = "...";


适合自己,做任何您喜欢的事情.


Suit yourself, do whatever you prefer.


如果使用@"而不是",则可以使用多行字符串:
You can have multi-line string if you use @"" instead of "":
string sqlQuery = @"
SELECT DocTemplate.DocTId, DocTemplate.DocTitle AS DocTitle, DocTemplate.TemplateAttachment AS TemplateAttachment, DocTemplate.PostDate AS PostDate, UserDocDefault.UserId, UserDocDefault.DateTo As DateTo, UserDocDefault.DateTill As DateTill 
FROM DocTemplate 
INNER JOIN UserDocDefault ON DocTemplate.DocTId = UserDocDefault.DocTId 
WHERE (UserDocDefault.UserId = 11003)";


"插入JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ"+
"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS"
"Insert into JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ" +
"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS"


这篇关于C#中的长插入查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆