generated from Avanade/avanade-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathIDatabaseMapper.cs
43 lines (38 loc) · 2.16 KB
/
IDatabaseMapper.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
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
using CoreEx.Entities;
using CoreEx.Mapping;
using System;
namespace CoreEx.Database
{
/// <summary>
/// Defines a database mapper.
/// </summary>
public interface IDatabaseMapper
{
/// <summary>
/// Gets the source <see cref="Type"/> being mapped from/to the database.
/// </summary>
Type SourceType { get; }
/// <summary>
/// Maps from a <paramref name="record"/> creating a corresponding instance of the <see cref="SourceType"/>.
/// </summary>
/// <param name="record">The <see cref="DatabaseRecord"/>.</param>
/// <param name="operationType">The single <see cref="OperationTypes"/> value being performed to enable conditional execution where appropriate.</param>
/// <returns>The corresponding instance of the <see cref="SourceType"/>.</returns>
object? MapFromDb(DatabaseRecord record, OperationTypes operationType = OperationTypes.Unspecified);
/// <summary>
/// Maps from a <paramref name="value"/> updating the <paramref name="parameters"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="parameters">The <see cref="DatabaseParameterCollection"/> to update from the <paramref name="value"/>.</param>
/// <param name="operationType">The single <see cref="OperationTypes"/> value being performed to enable conditional execution where appropriate.</param>
void MapToDb(object? value, DatabaseParameterCollection parameters, OperationTypes operationType = OperationTypes.Unspecified);
/// <summary>
/// Maps the <paramref name="key"/> and adds to the <paramref name="parameters"/>.
/// </summary>
/// <param name="key">The primary <see cref="CompositeKey"/>.</param>
/// <param name="parameters">The <see cref="DatabaseParameterCollection"/>.</param>
/// <remarks>This is used to map the only the key parameters; for example a <b>Get</b> or <b>Delete</b> operation.</remarks>
void MapKeyToDb(CompositeKey key, DatabaseParameterCollection parameters);
}
}