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

Named connection strings - using standard ConnectionStrings section in appsettings.json #6

Merged
merged 16 commits into from
Jul 25, 2019

Conversation

satano
Copy link
Member

@satano satano commented Jul 3, 2019

Closes #4

@satano satano requested review from Burgyn and LukasSefcik July 3, 2019 20:15
Copy link
Member

@Burgyn Burgyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

I have one question: How do I add another connection string with a different credential for migration?

@satano satano changed the title Named connection strings - using standard ConnectionStrings section in appsettings.json WIP Named connection strings - using standard ConnectionStrings section in appsettings.json Jul 11, 2019
@satano satano changed the title WIP Named connection strings - using standard ConnectionStrings section in appsettings.json Named connection strings - using standard ConnectionStrings section in appsettings.json Jul 24, 2019
/// </summary>
/// <param name="factory">Database factory.</param>
/// <returns>Database instance.</returns>
public static IDatabase GetDatabase(this IDatabaseFactory factory)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this method is like extension method and not directly in interface?


services.AddKorm("server=localhost-1", "db1");
services.AddKorm("server=localhost-2");
services.AddKorm("server=localhost-3", "db3");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this connection string with name db3 is added? It is not used.

action.Should().Throw<ArgumentException>().And.ParamName.Should().Be("name");
}

[Fact]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add one test to verify that IDatabase instance is disposed after the scope ended.

throw new ArgumentException(string.Format(Resources.DuplicateDatabaseName, name), nameof(name));
}
builders.Add(name, builder);
return builders.Count == 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very confusing for me. When the method Add.. returns a boolean, I assume that return true is if item added successfully. I looked at it for a long time, as long as I understood.

@satano satano merged commit 7f0b19e into master Jul 25, 2019
@satano satano deleted the NamedConnectionStrings branch July 25, 2019 07:44
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

Successfully merging this pull request may close these issues.

Use ConnectionStrings section with named connection strings
2 participants