generated from Avanade/avanade-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEfDbServiceCollectionExtensions.cs
More file actions
29 lines (26 loc) · 1.62 KB
/
EfDbServiceCollectionExtensions.cs
File metadata and controls
29 lines (26 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
using CoreEx.EntityFrameworkCore;
namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Provides <see cref="IServiceCollection"/> extenstion methods.
/// </summary>
public static class EfDbServiceCollectionExtensions
{
/// <summary>
/// Adds the <typeparamref name="TEfDb"/> as a scoped service.
/// </summary>
/// <typeparam name="TEfDb">The corresponding entity framework <see cref="IEfDb"/> implementation <see cref="Type"/>.</typeparam>
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
/// <returns>The <see cref="IServiceCollection"/> to support fluent-style method-chaining.</returns>
public static IServiceCollection AddEfDb<TEfDb>(this IServiceCollection services) where TEfDb : class, IEfDb => services.AddScoped<TEfDb>();
/// <summary>
/// Adds the <typeparamref name="TEfDb"/> as a scoped <typeparamref name="TIEfDb"/> service.
/// </summary>
/// <typeparam name="TIEfDb">The corresponding entity framework <see cref="IEfDb"/> service <see cref="Type"/>.</typeparam>
/// <typeparam name="TEfDb">The corresponding entity framework <typeparamref name="TIEfDb"/> implementation <see cref="Type"/>.</typeparam>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddEfDb<TIEfDb, TEfDb>(this IServiceCollection services) where TIEfDb : class, IEfDb where TEfDb : class, TIEfDb => services.AddScoped<TIEfDb, TEfDb>();
}
}