generated from Avanade/avanade-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDatabaseArgs.cs
56 lines (47 loc) · 2.15 KB
/
DatabaseArgs.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
using System;
namespace CoreEx.Database.Extended
{
/// <summary>
/// Provides the extended <see cref="IDatabase"/> arguments.
/// </summary>
public struct DatabaseArgs
{
private readonly IDatabaseMapper? _mapper = null;
/// <summary>
/// Initializes a new instance of the <see cref="DatabaseArgs"/> struct.
/// </summary>
public DatabaseArgs() { }
/// <summary>
/// Initializes a new instance of the <see cref="DatabaseArgs"/> struct.
/// </summary>
/// <param name="template">The template <see cref="DatabaseArgs"/> to copy from.</param>
/// <param name="mapper">The <see cref="IDatabaseMapper"/>.</param>
public DatabaseArgs(DatabaseArgs template, IDatabaseMapper mapper)
{
_mapper = mapper.ThrowIfNull(nameof(mapper));
Refresh = template.Refresh;
}
/// <summary>
/// Initializes a new instance of the <see cref="DatabaseArgs"/> struct.
/// </summary>
/// <param name="mapper">The <see cref="IDatabaseMapper"/>.</param>
public DatabaseArgs(IDatabaseMapper mapper) => _mapper = mapper.ThrowIfNull(nameof(mapper));
/// <summary>
/// Gets the <see cref="IDatabaseMapper"/>.
/// </summary>
public readonly IDatabaseMapper Mapper => _mapper ?? throw new InvalidOperationException("Mapper must have been specified for it to be referenced.");
/// <summary>
/// Indicates whether the <see cref="Mapper"/> has been specified.
/// </summary>
public readonly bool HasMapper => _mapper != null;
/// <summary>
/// Indicates whether the data should be refreshed (reselected where applicable) after a <b>save</b> operation (defaults to <c>true</c>).
/// </summary>
public bool Refresh { get; set; } = true;
/// <summary>
/// Indicates whether the result should be <see cref="Entities.Cleaner.Clean{T}(T)">cleaned up</see>.
/// </summary>
public bool CleanUpResult { get; set; } = false;
}
}