Thursday 7 January 2016

ASP.NET Tips #64 - Avoid issues with string queries

Instructing Entity Framework to use the right kind of string when generating queries can resolve datatype conversion issues. A simple solution is to introduce Column Annotation:

public class MyTable
{
   [Column(TypeName="varchar")]
   public string Property1 { get; set; }
}

This is particularly valid for string datatypes where .NET Strings are Unicode by default and are not the same in SQL Server.

For more information, see: http://www.simple-talk.com/dotnet/.net-tools/catching-performance-issues-in-development/

No comments :

Post a Comment