ExecuteScalarOrDefault Throws Exceptions
Deantwo opened this issue · 4 comments
I think you might have misunderstood the normal behavior of "OrDefault" methods in C#.
Normally a "OrDefult" method returns null
when the non-"OrDefault" version of the method would through an exception. Well it would throw the default(T)
of whatever the return type is, which for a string
is null
.
I am not completely sure what your version of "OrDefault" methods are supposed to do.
tik4net/tik4net/Api/ApiCommand.cs
Line 290 in 583c41e
tik4net/tik4net/Api/ApiCommand.cs
Line 295 in 583c41e
tik4net/tik4net/Api/ApiCommand.cs
Line 300 in 583c41e
I will confess that I had you implement these "OrDefault" methods, but I hadn't had the chance to test them myself before recently.
Hi Deantwo,
could you please close this issue or explain the problem. I agree with your description, but I believe that the behavior is as described :-)
Thx,
D
Main issue is, as the title says, the methods throw an exception.
tik4net/tik4net/Api/ApiCommand.cs
Line 336 in 583c41e
And also that the string defaultValue
parameter seems pointless and a little confusing. It would be simpler to just always return null
if the command resulted in more than one or no values. Like a normal SingleOrDefault
method.
I think I might have misunderstood something here when I made this bug report. So I am just gonna close this.
But I have found an issue though, I will make a new bug report for that.