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

Why enforce type constraint at the class level? #26

Open
mikebeaton opened this issue May 25, 2020 · 2 comments
Open

Why enforce type constraint at the class level? #26

mikebeaton opened this issue May 25, 2020 · 2 comments
Labels
question Further information is requested

Comments

@mikebeaton
Copy link
Member

Issue raised on medium.com:

Hi Mike, Looks like a promising Micro-Orm and I’ll be sure to try it, but may I ask why you enforce a type constraint at the class level rather than allowing people pass in the return type as an parameter?

Query result objects are quite often specific to the query or stored proc, and having to inject an instance of MightyOrm class each query return type seems a bit laborious.

It was something I never understood about Dapper.MicroOrm.Repositories either, given that under the hood all methods are invoking a protected method with the class type argument.

If there is a good reason, might I suggest allowing people to optionally override the result type my passing the method a type argument?

@mikebeaton mikebeaton added the question Further information is requested label May 25, 2020
@mikebeaton
Copy link
Member Author

mikebeaton commented May 25, 2020

My response:

The short answer is: that’s how Massive worked, and my aim was to write a compatible library. Even though I’ve added strong typing, Massive was written to encourage creating new instances ad hoc as required and each given instance’s table-specific commands were tied to a given table, as in Mighty.

As a slightly longer answer, I wonder if you might possibly be looking for this piece of info from Stack Overflow: “Generic repository in ASP.NET Core without having a separate AddScoped line per table in Startup.cs?

Also, look out for version 4 of Mighty where .ResultsAs will move from the work-in-progress code branch to the release NuGet package. You could use that feature to do what you specifically want. Though with the generic injector pattern, maybe you won’t need to.

@mikebeaton
Copy link
Member Author

OP's response:

Thanks for your reply. The generic repository pattern works pretty well for typical CRUD operations on tables but executing stored procs or more complicated queries can can become a bit of a pain point, but the ResultsAs method on the mighty API seems to solve that quite elegantly.

Thanks I will be sure to put your library to use.

@mikebeaton mikebeaton mentioned this issue Mar 21, 2021
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant