MSSQL nvarchar(max) in Aurelius results in garbage

It seems Aurelius doe not properly handle the nchar/nvarchar MSSQL data type when used from blog


The following code will result is garbage being saved to the database:

LogItem.l_text.AsString := 'Some Text';

To correctly save the text, i have to do the following:

LogItem.l_text := TEncoding.Unicode.GetBytes('Some Text');

Yes, that's how you should do it? What you mean by "not properly handle"? Just use it in the correct way.

You can also use


LogItem.I_text.AsUnicodeString := 'Some Text';


AsUnicodeString is for Unicode encoding.
AsString is for ANSI encoding.

Thank you for your answer. I was confused by the documentation that states:


Use AsString property to read/set the blob content as string

 

If you want to work with the blob content as string, you can just use AsString property for that:

 

Customer1.Photo.AsString := 'Set string directly to the blob';


I expected Aurelius to take core of the conversion from the native string to whatever is supported by the underlying storage system - in particular since none is required in this case.

Thanks for pointing out. We will improve the documentation in that regard.

Aurelius does exactly that, that's why there is AsUnicodeString. The "AsString" is kept like that for backward compatibility.