Faster way to get SQL compatible string from Guid

I noticed this particular line of code when I was profiling my application (which creates a database insert boat, processing some raw data):

myStringBuilder.AppendLine(
    string.Join(
        BULK_SEPARATOR, new string[]{myGuid.ToString() ...

Given that the resulting line will be completed in the file called by the TSQL command BULK INSERT, is there a way to make this step faster? I know that getting a byte array is faster, but I can't just attach it to a file.

+3
source share
3 answers

- BULK INSERT . SqlBulkCopy. , .

( Guid - , 100% , SqlBulkCopy .)

+2

, . , , , , ToString Guid, .

, , , , ( , ):

  • myStringBuilder ? Length (not the Capacity) 0, , . StringBuilder, .

  • myStringBuilder String.Join. String.Join , , ( ) . . , , ( , , ), Append, guid, BULK_SEPARATOR. , btw, Length StringBuilder , .

0

- GUID, , ? #, , , SQL Server, ?

0
source

Source: https://habr.com/ru/post/1733076/


All Articles