可空类型 [英] Nullable Types
本文介绍了可空类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚在net 2.0中发表了关于Nullable类型的一些内容。
http://stevenr2.blogspot.com/2006/01...oalescing.html
问题至于为什么你不能简单地从
..Net值类型转换为Sql Server数据类型,而不是必须使用null
cheked和DBNull.Value?
有没有人有一些解释为什么这是如此棘手呢?
包括在内?
> http://stevenR2.com
I''ve just blogged some stuff on Nullable types in net 2.0.
http://stevenr2.blogspot.com/2006/01...oalescing.html
Question however as to why you can''t simply get an implcit conversion from a
..Net value type to to a Sql Server data type rather than having to use null
cheked and DBNull.Value ?
Does anyone have some explanation as to why this is so tricky as to be
included?
http://stevenR2.com
推荐答案
当然我的意思是 - 不包括在内...... :)
" Steven Livingstone" <共***** @ NOSPAM.stevenR2.com>在留言中写道
news:%2 *************** @ tk2msftngp13.phx.gbl ...
of course i meant - as not to be included... :)
"Steven Livingstone" <co*****@NOSPAM.stevenR2.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
我是我刚刚在net 2.0中发表了关于Nullable类型的一些内容。
http://stevenr2.blogspot.com/2006/01...oalescing.html
然而问题为什么你不能简单获得从.Net值类型到Sql Server数据类型的implcit转换,而不是必须使用
null cheked和DBNull.Value?
有没有人有一些解释至于为什么要包括这么简单?
http: //stevenR2.com
I''ve just blogged some stuff on Nullable types in net 2.0.
http://stevenr2.blogspot.com/2006/01...oalescing.html
Question however as to why you can''t simply get an implcit conversion from
a .Net value type to to a Sql Server data type rather than having to use
null cheked and DBNull.Value ?
Does anyone have some explanation as to why this is so tricky as to be
included?
http://stevenR2.com
FWIW,有一段时间讨论了这个问题(
$ b $至少VB的一部分,你必须假设C#)。
http://blogs.msdn.com/vbteam/archive...13.aspx#159656
似乎MS认为它。所以,要么我错过了一些东西,它已经完成了,或者他们选择不这样做。
史蒂文:: http://stevenR2.com
" Steven Livingstone" <共***** @ NOSPAM.stevenR2.com>在留言中写道
news:%2 *************** @ tk2msftngp13.phx.gbl ...
FWIW, there was a discussion a while back where this was considered (at
least a part of VB and you''d have to assume C#).
http://blogs.msdn.com/vbteam/archive...13.aspx#159656
Seems MS considered it. So either i''m missing something and it''s already
done, or they chose not to do it.
steven :: http://stevenR2.com
"Steven Livingstone" <co*****@NOSPAM.stevenR2.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
我是我刚刚在net 2.0中发表了关于Nullable类型的一些内容。
http://stevenr2.blogspot.com/2006/01...oalescing.html
然而问题为什么你不能简单获得从.Net值类型到Sql Server数据类型的implcit转换,而不是必须使用
null cheked和DBNull.Value?
有没有人有一些解释至于为什么要包括这么简单?
http: //stevenR2.com
I''ve just blogged some stuff on Nullable types in net 2.0.
http://stevenr2.blogspot.com/2006/01...oalescing.html
Question however as to why you can''t simply get an implcit conversion from
a .Net value type to to a Sql Server data type rather than having to use
null cheked and DBNull.Value ?
Does anyone have some explanation as to why this is so tricky as to be
included?
http://stevenR2.com
史蒂文,
这不是很棘手,真的。 SQL可空类型意味着特定域空间的特定解决方案。 Nullable类型扩展
到更大的空间。
另外,我相信可以为空的类型是替代品,而不是
一个互操作机制。
我不知道这肯定是合理的。
如果有的话,我认为SQL nullables将会消失(意思是,
它们将留在那里以实现向后兼容性),现在已经有了一般的
解决方案。
希望这会有所帮助。
" Steven Livingstone" <共***** @ NOSPAM.stevenR2.com>在留言中写道
news:%2 *************** @ tk2msftngp13.phx.gbl ...
Steven,
It''s not tricky, really. The SQL nullable types were meant as a very
specific solution to a particular domain space. Nullable types are extended
to a much larger space.
Also, I believe that nullable types are meant to be a replacement, not
an interop mechanism.
I don''t know that this necessarily justifies it, though.
If anything, I think that the SQL nullables will just go away (meaning,
they will be left in there for backwards compatability), now that a general
solution is in place.
Hope this helps.
"Steven Livingstone" <co*****@NOSPAM.stevenR2.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
我是我刚刚在net 2.0中发表了关于Nullable类型的一些内容。
http://stevenr2.blogspot.com/2006/01...oalescing.html
然而问题为什么你不能简单获得从.Net值类型到Sql Server数据类型的implcit转换,而不是必须使用
null cheked和DBNull.Value?
有没有人有一些解释至于为什么要包括这么简单?
http: //stevenR2.com
I''ve just blogged some stuff on Nullable types in net 2.0.
http://stevenr2.blogspot.com/2006/01...oalescing.html
Question however as to why you can''t simply get an implcit conversion from
a .Net value type to to a Sql Server data type rather than having to use
null cheked and DBNull.Value ?
Does anyone have some explanation as to why this is so tricky as to be
included?
http://stevenR2.com
这篇关于可空类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文