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

Add columns support to Single overload #289

Open
mikebeaton opened this issue Jan 29, 2017 · 1 comment
Open

Add columns support to Single overload #289

mikebeaton opened this issue Jan 29, 2017 · 1 comment

Comments

@mikebeaton
Copy link
Contributor

mikebeaton commented Jan 29, 2017

The version of Single() at line 509 of Massive.Shared.cs with signature public virtual dynamic Single(string where, params object[] args) does not support a columns argument.

This would actually be very useful to have. I think so because I needed it in the project I'm working on, and added it for myself and used it a lot, and I think so because All() supports columns, and the other explicit version of Single() supports columns, and all the rather cryptic variants of Single() which are dynamically supported by TryInvokeMember support columns.

It's easy to add an optional columns param, with default value * to this method (which is what I did), and this would link against existing code, but I think from your contribution guidelines it should be added as another new method.

@mikebeaton mikebeaton mentioned this issue Feb 9, 2017
@mikebeaton
Copy link
Contributor Author

mikebeaton commented Feb 10, 2017

This is definitely (or almost definitely, see last para below...) a breaking change. The obvious new method signature is public virtual dynamic Single(string where, string columns = "*", params object[] args) (to replace public virtual dynamic Single(string where, params object[] args)). But this will break existing code, causing, e.g., db.Single("BusinessEntityID=@0", 1234) to no longer compile.

It appears at first that something even worse would happen, namely that db.Single("CompanyName=@0", "Microsoft") would compile and run, but the intended string parameter would become newly misinterpreted as a columns specification. Actually this problem cannot happen, only because db.Single("CompanyName=@0", "Microsoft") cannot be in previous code as it would previously have refused to compile(!), due to ambiguity with the public virtual dynamic Single(object key, string columns = "*") method signature. (This call would however start to compile and behave incorrectly, given the new Single method signature... but you wouldn't ever add it, because IntelliSense would be telling you that you were putting args into a columns parameter!)

Despite all that, it would still actually be possible to support a columns plus args variant of Single without breaking any existing code, if it was supported dynamically (but only dynamically, c.f. #287) in TryInvokeMember - because dynamically supported methods are only invoked if no explicitly defined method can be used. That assumes that TryInvokeMember can itself be refactored to fully and correctly support args (cf #285 which attempts this, but does not succeed) - which in fact it can be in principle, but only if named args support is added...

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

1 participant