C# 3.0 in a Nutshell
C# 3.0 in a Nutshell, Third Edition A Desktop Quick Reference By Joseph Albahari, Ben Albahari
September 2007
Pages: 858


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Sql Columns Defined As Nvarchar(1)
sgmoore
post May 19 2009, 10:34 AM
Post #1


New Member
*

Group: Members
Posts: 9
Joined: 20-November 08
Member No.: 1,589



Not sure whether this is part of LinqPad or the Framework, but if you have a Sql table with a column of type NVarChar and length 1, then it is mapped to char? instead of string? which causes a problem if the column contains an empty string.

Is there a way of fixing this?

Go to the top of the page
 
+Quote Post
JoeAlbahari
post May 19 2009, 06:54 PM
Post #2


Advanced Member
******

Group: Members
Posts: 207
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



Good point. LINQPad maps char(1) columns to a char type from version 1.35 to be consist with SqlMetal and Visual Studio's designer.

You can disable this in Edit | Preferences | Query although this will disable support for 1:1 relationships as well. Perhaps I should decouple these two things in the next update.

Joe
Go to the top of the page
 
+Quote Post
sgmoore
post May 21 2009, 12:30 AM
Post #3


New Member
*

Group: Members
Posts: 9
Joined: 20-November 08
Member No.: 1,589



QUOTE (JoeAlbahari @ May 19 2009, 06:54 PM) *
Good point. LINQPad maps char(1) columns to a char type from version 1.35 to be consist with SqlMetal and Visual Studio's designer.

You can disable this in Edit | Preferences | Query although this will disable support for 1:1 relationships as well. Perhaps I should decouple these two things in the next update.

Joe


Thanks. If you could decouple them it would be great as the 1:1 relationships is too nice a feature to lose.
Go to the top of the page
 
+Quote Post
rubyjackson
post Jul 12 2009, 10:06 PM
Post #4


New Member
*

Group: Members
Posts: 1
Joined: 12-July 09
Member No.: 19,144



That was really a great post and information - just bookmarked and keep up the good work


--------------------
Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jul 13 2009, 04:53 AM
Post #5


Advanced Member
******

Group: Members
Posts: 207
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



You might like to download the latest preview of LINQPad:
http://www.linqpad.net/preview/LINQPad.exe

I've permanently disabled the mapping of nvarchar(1) to char - it now maps to string instead.

nchar(1) and char(1) however, still map to the char type.

This should take care of nearly all scenarios.

Joe
Go to the top of the page
 
+Quote Post
sgmoore
post Jul 15 2009, 05:43 AM
Post #6


New Member
*

Group: Members
Posts: 9
Joined: 20-November 08
Member No.: 1,589



QUOTE (JoeAlbahari @ Jul 13 2009, 04:53 AM) *
You might like to download the latest preview of LINQPad:
http://www.linqpad.net/preview/LINQPad.exe


Yes, that works fine.

Thank you very much.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 7th November 2009 - 05:52 PM