aleXela
aleXela

Reputation: 1301

Get nullable results from System.Data.SQLite for a string for multiple columns (without if check)

Tried to find by myself, no luck.

I have classes with a lot of properties internal string? Driver { get; set; } as example.

Im converting SQLDataReader object to the class: swTmpObject.Driver = item.GetString(item.GetOrdinal("driver")). The property is nullable.

But as I understand GetString cannot take Null to it.

I can use IsDBNull to check every field before converting. But I have a lot of properties.

Also I have an option to use string a = item.GetValue(item.GetOrdinal("driver")).ToString(), but I prefer using Null instead.

Can I make it some how more efficient?

Thanks

Upvotes: 0

Views: 26

Answers (0)

Related Questions