SQLDataReader를 사용하여 데이터베이스에서 null 값을 검색하고 있습니다. SQL 데이터 판독기 - Null 열 값을 우아하게 처리하는 방법
Using cmd As DbCommand = store.GetStoredProcCommand("RetrievePOCO")
store.AddInParameter(cmd, "ID", DbType.Int32, ID)
Using reader As IDataReader = store.ExecuteReader(cmd)
If reader.Read() = True Then
Dim newPOCO As New POCO()
With newPOCO
'If the source column is null TryCast will return nothing without throwing an error
.StatusXML = TryCast(reader.GetString(reader.GetOrdinal("StatusXML")), String)
'How can a null integer or boolean be set elegantly?
.AppType = TryCast(reader.GetInt32(reader.GetOrdinal("AppType")), System.Nullable(Of Integer))
.Archived = TryCast(reader.GetBoolean(reader.GetOrdinal("Archived")), Boolean)
그래서 널 정수 또는 부울 우아한 방법을 설정할 수 있습니다 내가 널 문자열 값을 처리 할 수 있지만 같은 트릭을 정수 또는 부울 작업을 얻을 수있는 방법을 일했다? C#에서 제안 사항을 보았지만 VB에서 올바르게 'TryCast 피연산자가 참조 유형이어야하지만 정수로 변환되지 않습니까? 값 유형 '컴파일러 오류입니다.
네가 지적한 것처럼 네가 굉장히 우아하지는 않다. 나는 더 깔끔한 것이 있으면 좋겠다. –