-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDatabaseMapperT2.cs
More file actions
22 lines (19 loc) · 1.12 KB
/
DatabaseMapperT2.cs
File metadata and controls
22 lines (19 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
using System;
namespace CoreEx.Database.Mapping
{
/// <summary>
/// Provides <see cref="DatabaseMapper{TSource}"/> with a singleton <see cref="Default"/>.
/// </summary>
/// <typeparam name="TSource">The source <see cref="Type"/>.</typeparam>
/// <typeparam name="TMapper">The mapper <see cref="Type"/>.</typeparam>
/// <remarks>Where performance is critical consider using <see cref="DatabaseMapperEx{TSource, TMapper}"/>.</remarks>
public abstract class DatabaseMapper<TSource, TMapper> : DatabaseMapper<TSource> where TSource : class, new() where TMapper : DatabaseMapper<TSource, TMapper>, new()
{
private static readonly TMapper _default = new();
/// <summary>
/// Gets the current instance of the mapper.
/// </summary>
public static TMapper Default => _default ?? throw new InvalidOperationException("An instance of this Mapper cannot be referenced as it is still being constructed; beware that you may have a circular reference within the constructor.");
}
}