这是确保字段具有数据库有效值的好方法吗?我如何验证分类字段?
internal class Customer
{
private string _CustomerId;
internal string CustomerId
{
get
{
return (_CustomerId==null?string.Empty:(_CustomerId.Length>20?_CustomerId.Substring(0,20):_CustomerId));
}
set
{
_CustomerId = value;
}
}}
问候斯文
你能提供更多关于你正在使用的细节吗?这是什么技术。你使用哪种数据库技术,以及你如何与它进行交互?这是Web/Windows/WPF /类库吗? – 2010-03-09 12:05:27
对不起 它在一个classlibray中。我正在为一个正在同步2个数据库的应用程序构建一个库。我的问题是,他们允许不同长度的表中的字段。 检查null是因为在提供空值时向sql查询添加参数时出现错误。 – Zwempha 2010-03-09 12:12:45