Skip to content
New issue

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

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

Already on GitHub? # to your account

Is there an IDatabase interface? #25

Closed
ThisNoName opened this issue Nov 7, 2015 · 2 comments
Closed

Is there an IDatabase interface? #25

ThisNoName opened this issue Nov 7, 2015 · 2 comments

Comments

@ThisNoName
Copy link

I was told it's easier to inject and unit test that way.

And speaking of interface, are you familiar with Insight.Database's automatic interface? It's something like this:

public interface IUserRepository { 
    [SQL("select * from user where id=@id")]
    List<User> GetUser(int id);

    [SQL("storedprocdoesstuff")]
    void DoStuff(Stuff stuff);
} 

And that's it. There's no code that actually implement the interface. You can call them directly and the framework wires up everything

IUserRepository repo = db.As<IUserRepository>();
repo.GetUser(1);

Technically, this is not much different from writing inline. But I always felt it worth the hassle just for the sake of having all SQL-ish code in one place.

@tmenier
Copy link
Owner

tmenier commented Aug 12, 2016

This has been contributed as a PR and accepted. I will update it on NuGet soon.

#29

@tmenier
Copy link
Owner

tmenier commented Aug 14, 2016

@tmenier tmenier closed this as completed Aug 14, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants