Consider a SQL Server table defined with a varchar(1) NULL
field. It's being used to store a gender character. Some rows have data, some not: either null or blank. Granted the blanks SHOULD be nulls, but consider that blank is a valid value here. I'd much prefer the value to be null.
ID Gender 1 'M' 4 'M' 3 '' 4 'F'
An exception is raised when running a Linq To Sql query where the value of someID
is 3.
var emp = (from e in db.Employees
where e.ID == someID
select e);
Exception:
String must be exactly one character long.
Question: What is the cause of this exception? What can be done to prevent or eliminate this problem?