Closed Deantwo closed 5 years ago
Made a simple extension method in my project:
internal static ITikSentence ExecuteSingleRowOrDefault(this ITikCommand command)
{
IEnumerable<ITikSentence> sentences = command.ExecuteList();
return sentences.SingleOrDefault();
}
Seem like it it would be a no brainer to implement in the tik4net. But can likely be written better than this.
On the topic of cmd.ExecuteSingleRow()
, it would be nice if the error message from it was made a little simpler.
tik4net.TikConnectionException: 'Command expected 2 sentences as response, but got 1 response sentences.'
The average user won't know that !done
is part of those, so saying it expected 2 sentences is confusing.
We currently have
cmd.ExecuteSingleRow()
which is very useful. At least if you are expecting there to be a result, or don't mind adding a try-catch just to be sure there isn't no results.I suggest a simple
cmd.ExecuteSingleRowOrDefault()
. Simply return null if no results were found.