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 DataContext to DI #6310

Open
wants to merge 3 commits into
base: release/10.0.0
Choose a base branch
from

Conversation

donker
Copy link
Contributor

@donker donker commented Jan 14, 2025

This PR adds DataContext to DI using AddTransient so the following pattern:

            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository<SqlQuery>();
                rep.Insert(query);
            }

to

        public ApiTokenRepository(IDataContext dataContext)
        {
            this.dataContext = dataContext;
        }

....

            var rep = this.dataContext.GetRepository<ApiToken>();
            return rep.GetById(apiTokenId);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants