Consider a SQL Server table defined with a field varchar(1) NULL. It is used to store gender. Some lines contain data, and some do not: either empty or empty. The spaces provided MUST be zeros, but consider that this is an empty value. I would prefer the value to be zero.
ID Gender
1 'M'
4 'M'
3 ''
4 'F'
An exception occurs when executing a Linq To Sql query, where the value someIDis 3.
var emp = (from e in db.Employees
where e.ID == someID
select e);
Exception
The string must be exactly one character long.
Question : What is the reason for this exception? What can be done to prevent or eliminate this problem?