aboutsummaryrefslogtreecommitdiff
path: root/docker/crupest-api/CrupestApi/CrupestApi.Commons/DatabaseHelper.cs
blob: 9eb6a08b785d0d3151b829338985a58a8489abb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
namespace CrupestApi.Commons;


public static class DatabaseHelper
{
    public static string GenerateUpdateColumnString(this IEnumerable<string> updateColumnList, IEnumerable<KeyValuePair<string, string>>? paramNameMap = null)
    {
        paramNameMap = paramNameMap ?? Enumerable.Empty<KeyValuePair<string, string>>();
        var paramNameDictionary = new Dictionary<string, string>(paramNameMap);

        return string.Join(", ", updateColumnList.Select(x => $"{x} = @{paramNameDictionary.GetValueOrDefault(x) ?? x}"));
    }
}