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

Massive - no way to create general purpose commands for Execute(DbCommand) #300

Closed
mikebeaton opened this issue Feb 9, 2017 · 4 comments

Comments

@mikebeaton
Copy link
Contributor

mikebeaton commented Feb 9, 2017

Massive.Shared.cs has public methods to execute a single command public virtual int Execute(DbCommand command) or a collection of commands public virtual int Execute(IEnumerable<DbCommand> commands).

However, there is no public way to create a correctly formed, general purpose Massive command, i.e. one created using var result = _factory.CreateCommand(); and then SetCommandSpecificProperties(result);, as currently done in private DbCommand CreateCommand(string sql, DbConnection conn, params object[] args);.

Because of the way Massive handles connections (in almost all cases creating them itself to execute what is passed in) it does not seem correct to just make private DbCommand CreateCommand(string sql, DbConnection conn, params object[] args); public, but it does seem to make good sense to provide a new public alias private DbCommand CreateCommand(string sql, params object[] args)?

Note that while the same functionality is already covered for a single command by public virtual int Execute(string sql, params object[] args) this still does not address the issue of not being able to create correct commands to pass to the other two variants of Execute, especially the multiple command variant.

@mikebeaton mikebeaton changed the title Massive - no way to create valid commans for Execute(DbCommand) Massive - no way to create valid commands for Execute(DbCommand) Feb 9, 2017
@mikebeaton
Copy link
Contributor Author

mikebeaton commented Feb 9, 2017

Apologies, I see that Massive supports CreateDeleteCommand, CreateInsertCommand, CreateUpdateCommand and CreateUpdateWhereCommand. So my original (pre-edited) point is incorrect, and the public Execute methods can certainly be used.

But it still seems it might make sense to also provide public access to a general purpose CreateCommand, as I suggested? (For instance, even in current Massive, this could be used to make a simple stored procedure command, to be executed along with other commands.)

@mikebeaton mikebeaton changed the title Massive - no way to create valid commands for Execute(DbCommand) Massive - no way to create general purpose commands for Execute(DbCommand) Feb 9, 2017
@FransBouma
Copy link
Owner

But it still seems it might make sense to also provide access to a general purpose CreateCommand, as I suggested? (For instance, even in current Massive, this could be used to make a simple stored procedure command, to be executed along with other commands.)

In general it helps if you have a concrete use case, i.e. you want to do things in way ABC and it can't be done unless feature X is added, which justifies the addition of X. It might very well be to do ABC, not X should be added but Y. (not that CreateCommand shouldn't be added, but there has to be a use case for it, for which it is the best option)

@mikebeaton
Copy link
Contributor Author

I agree that I do not have a concrete use case, just a general idea that if Massive already has a public way to accept and execute a sequence of Massive commands, then it makes sense to provide the user with the full flexibility to generate those commands.

If the user did currently want to execute a sequence of commands which included something which the four currently public CreateXXX methods do not support (e.g. an SP call) then it would look very tempting to pass in a DbCommand which they had created themselves (i.e. not via Massive) as part of their IEnumerable list - but this would be potentially incorrect since a user generated DbCommand is not correctly initialised.

@mikebeaton
Copy link
Contributor Author

Should I close these (#300, #301) for now? They're both not urgent (at the highest!), and both only occurred to me as a result of trying to match my own Create and Execute patterns for proposed SP support (#293) to what is already in there.

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