Sunday 8 November 2009 @ 10:49 am
Just a quick post in case anyone is wasting 10 minutes figuring out how to do this. For me, this came up because in Sql Server 2008, NVARCHAR(MAX) is 4000 characters and I needed more. The recommended datatype to use for more is VARBINARY. When I did that, LINQ2SQL converted that type to Linq.Binary. (using encoding)
So, in my C# code, here is what you need to convert to the Linq.Binary:
Linq.Binary carrierMatrix =
new ASCIIEncoding().GetBytes(myString);And, to go back from Linq.Binary:
string carrierMatrixString = Encoding.ASCII.GetString(carrierMatrix.ToArray());
Hope this help!











February 1st, 2010 at 4:14 am
thank you so much. it really helped