Is it possible to convert a C # string to SqlChars?

I am creating some unit tests for a piece of code that returns a SqlGeography type. To fake a SqlGeography column, I would like to use SqlGeography.STLineFromText to create a row. The problem is that STLineFromText takes SqlChars as a parameter. Does anyone know how to convert a C # string to SqlChars?

+4
source share
3 answers
new SqlChars(new SqlString(text)); 
+10
source

Use this:

 new SqlChars(text.ToCharArray()); 
+3
source

You can use the SqlChars constructor :

 SqlChars c = new SqlChars("test".ToArray()); 
+2
source

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


All Articles