I have too a problem with these kind of fields so I add what happens to me:
I have constants with multiline string fields that usually contain SQL Server Query code.
1) In one case, the constant is just put at the end of the class.
2) In the other case Visual Studio hangs, with the disk writing furiously as if it was allocating megabytes of ram and the swap disk was trying to follow the requests, while the cooling fan goes to maximum speed.
The machine is running Visual Studio 2010 on Vista Business 32Bit.
A message appears on visual studio status bar telling the following:
[16.50.09]Regionerate: non critical warning : the following unrecognized piece of code was detected "private const string SQL_GetThreadConnections = @"....
the rest of the string goes beyond the monitor size anywhay the problem is with the constants so I put them in this message to let you try what happens,
I gave a try in a class1 object creating a simple region around the constructor and the hang on happens imediately.
These are the incriminated constants
- Code: Select all
private const string SQL_GetThreadConnections = @"
SELECT IDAzienda, IDGenericConnection, IDTabellaTo, PKTabellaTo,
CASE WHEN IDTabellaTo = 'TbForumsThreads' THEN
(SELECT DDForumsThread FROM TbForumsThreads thr WHERE thr.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), thr.IDForumsThread) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbContacts' THEN
(SELECT IDContactSearch FROM TbContacts ctt WHERE ctt.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), ctt.IDContact) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbContactsPersone' THEN
(SELECT isnull(IDContactsTitolo,'')+ isnull(DDContactPersonaNome,'') +' '+ isnull(DDContactsPersonaCognome,'') AS Persona FROM TbContactsPersone per WHERE per.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), per.IDContactPersona) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbDocumentiTs' THEN
(SELECT CodiceDocumento+' '+ isnull(DDDocumento,'') +' '+ isnull(Convert(nvarchar(10), DataDocumento, 103),'') AS Documento FROM TbDocumentiTs dts WHERE dts.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), dts.IDDocumentoTs) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbDocumentiRg' THEN
(SELECT CodiceDocumento+' '+ isnull(Revisione,'') +' '+ isnull(DDDocumento,'') AS Documento FROM TbDocumentiRg drg WHERE drg.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), drg.IDDocumentoRg) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbDocumentiSpaziElements' THEN
(SELECT CodeDocumentiSpaziElement+' '+ isnull(DDDocumentiSpaziElement,'') AS Spazio FROM TbDocumentiSpaziElements spz WHERE spz.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), spz.IDDocumentiSpaziElement) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbWorkItems' THEN
(SELECT isnull(Convert(nvarchar(10), StartDatetime, 103),'')+' '+ isnull(DDWorkitem,'') AS Scadenza FROM TbWorkItems sca WHERE sca.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), sca.IDWorkItem) = cnn.PKTabellaTo)
ELSE
'Tabella non definita: ' + cnn.IDTabellaTo +' '+ cnn.PKTabellaTo
END
AS DDConnection
FROM [TbGenericConnections] cnn
WHERE
(cnn.IDAzienda = @IDAzienda
AND
cnn.IDTabellaFrom = 'TbForumsThreads'
AND
cnn.PKTabellaFrom = @IDForumsThread)";
private const string SQL_GetRootThreadConnections = @"
SELECT IDAzienda, IDGenericConnection, IDTabellaTo, PKTabellaTo,
CASE WHEN IDTabellaTo = 'TbForumsThreads' THEN
(SELECT DDForumsThread FROM TbForumsThreads thr WHERE thr.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), thr.IDForumsThread) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbContacts' THEN
(SELECT IDContactSearch FROM TbContacts ctt WHERE ctt.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), ctt.IDContact) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbContactsPersone' THEN
(SELECT isnull(IDContactsTitolo,'')+ isnull(DDContactPersonaNome,'') +' '+ isnull(DDContactsPersonaCognome,'') AS Persona FROM TbContactsPersone per WHERE per.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), per.IDContactPersona) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbDocumentiTs' THEN
(SELECT CodiceDocumento+' '+ isnull(DDDocumento,'') +' '+ isnull(Convert(nvarchar(10), DataDocumento, 103),'') AS Documento FROM TbDocumentiTs dts WHERE dts.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), dts.IDDocumentoTs) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbDocumentiRg' THEN
(SELECT CodiceDocumento+' '+ isnull(Revisione,'') +' '+ isnull(DDDocumento,'') AS Documento FROM TbDocumentiRg drg WHERE drg.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), drg.IDDocumentoRg) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbDocumentiSpaziElements' THEN
(SELECT CodeDocumentiSpaziElement+' '+ isnull(DDDocumentiSpaziElement,'') AS Spazio FROM TbDocumentiSpaziElements spz WHERE spz.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), spz.IDDocumentiSpaziElement) = cnn.PKTabellaTo)
WHEN IDTabellaTo = 'TbWorkItems' THEN
(SELECT isnull(Convert(nvarchar(10), StartDatetime, 103),'')+' '+ isnull(DDWorkitem,'') AS Scadenza FROM TbWorkItems sca WHERE sca.IDAZienda = cnn.IDAzienda and
convert(nvarchar(255), sca.IDWorkItem) = cnn.PKTabellaTo)
ELSE
'Tabella non definita: ' + cnn.IDTabellaTo +' '+ cnn.PKTabellaTo
END
AS DDConnection
FROM
(
SELECT [IDAzienda]
,[IDGenericConnection]
,[IDTabellaTo]
,[PKTabellaTo]
FROM [TbGenericConnections] gcn
WHERE
(gcn.IDAzienda = @IDAzienda
AND
gcn.IDTabellaFrom = 'TbForumsThreads'
AND
gcn.PKTabellaFrom = @IDForumsThread)
OR
Exists (SELECT 1 FROM TbForumsThreads thr WHERE
convert( nvarchar(255), thr.IDForumsThreadAncestor) = @IDForumsThread
AND thr.IDAzienda = gcn.IDAzienda AND convert( nvarchar(255), thr.IDForumsThread) = gcn.[PKTabellaFrom])) cnn
";
hope this can help
regards
Sabrina