Abhijeet
Abhijeet

Reputation: 13856

Why does EntityFramework trims out UTF encoded string?

Encoding.UTF8.GetString(inBytes, 0, inBytes.Length)

"�\0\0ID\0\0\0\0NJ\0SchemaVersion\0\0\0\0RequestType\0\0\0\0\n"

Above string when being saved to database using EntityFramework is clipped out to a single character '�'

Does EntityFramework trim the string behind the scenes? Probably to prevent SQL injections!

More Info:

I obtained a long UTF8 encoded string and trying to save into SQL server database using entity framework. Target column is of datatype nvarchar(max) & EF mapping to C# is string.

I have looked for this variable in quick watch and is properly assigned to dbcontext table property.

Upvotes: 2

Views: 330

Answers (1)

Abhijeet
Abhijeet

Reputation: 13856

The issue was lot of '\0' characters in the encoded string. It was being treated as null character identifying end of string.

So I had to handle these characters in characters array to process it.

Upvotes: 1

Related Questions