I have a very nasty problem with LINQ and MS SQL Server.
Im currently creating some software in C # WPF and is using LINQ to generate classes from the data in the database.
However, when I update the nvarchar or varchar field in the database from my program, LINQ adds trailing spaces to the string!
I have a field in a table defined as follows:
ProductName = NVARCHAR(10)
So, if I do this:
Product.Name = "Bike";
Product.Name = Product.Name.Trim();
repository.Add(Product);
repository.Save();
then the resulting data in the database: "Bike [SPACE] [SPACE] [SPACE] [SPACE] [SPACE] [SPACE]", where [SPACE] is just a space (cannot write several spaces in this text here).
Why is he doing this, and how do I get him to stop adding these annoying trailing spaces?
Thanks in advance