C# 拼SQL语句时string 类型的null值为何自动转化为‘’,该如何书写?

2025-04-29 07:01:00
推荐回答(3个)
回答1:

用sql自带的函数ISNULL()

SELECT * FROM product WHERE Id=ISNULL(Id,'')

回答2:

添加判断
if (string.IsNullOrEmpty(id))
{
id = " "
}

回答3:

string id='null';