Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] ExecuteSingleRowOrDefault #58

Closed
Deantwo opened this issue Jan 4, 2019 · 2 comments
Closed

[Suggestion] ExecuteSingleRowOrDefault #58

Deantwo opened this issue Jan 4, 2019 · 2 comments
Assignees

Comments

@Deantwo
Copy link
Contributor

Deantwo commented Jan 4, 2019

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.

@Deantwo
Copy link
Contributor Author

Deantwo commented Jan 4, 2019

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.

@Deantwo
Copy link
Contributor Author

Deantwo commented Jan 4, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants