LINQ to SQL 中数据库中存在空字符串的错误
我已经使用 LINQ to SQL 多年了,但这是我第一次看到这种行为。
我有一个数据库表,其中有几列 (varchar(15)
),其中可能包含空字符串 (''
)。我通过运行 LEN(Column)
并检查结果为 0
来验证这一点。
现在,当我从 LINQ2SQL 调用它时,它返回对象字段,其中包含一个包含单个空格的字符串 (string.Length == 1
)。
我可以应用一些解决方法,例如在数据库上将它们设为 NULL
或修剪字符串,但我想知道之前是否有人遇到过这种情况,或者该错误是否已知(报告于微软连接)。如果没有,我会报告。
谢谢。
I have been using LINQ to SQL for years now, but this is the first time I have seen this behavior.
I have a DB table with a few columns (varchar(15)
) that may contain empty strings (''
). I verify this by running LEN(Column)
and checking the result be 0
.
Now when I call this from LINQ2SQL, it returns the object field with a string containing a single space (string.Length == 1
).
There are a few workarounds I could apply, like making them NULL
on the DB or trimming the string, but I would like to know if anyone has come across this before or if the bug is known (reported on MS Connect). If not, I'll report it.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在
LEN
函数上:在 SQL Server 中返回 0;这是一个完整的 PITA。
但
返回 1
The issue is with the
LEN
function:Returns 0 in SQL Server; it is a total PITA.
But
Returns 1