-
-
Notifications
You must be signed in to change notification settings - Fork 524
Expand file tree
/
Copy pathCollectionExtensions.cs
More file actions
30 lines (25 loc) · 821 Bytes
/
CollectionExtensions.cs
File metadata and controls
30 lines (25 loc) · 821 Bytes
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
using System.Collections.Generic;
using System.Linq;
namespace SqlKata.Extensions
{
public static class CollectionExtensions
{
public static Dictionary<string, object> MergeKeysAndValues(this List<string> keys, List<object> values)
{
var data = new Dictionary<string, object>();
for (var i = 0; i < keys.Count; i++)
{
data.Add(keys[i], values[i]);
}
return data;
}
public static Dictionary<string, object> CreateDictionary(this IEnumerable<KeyValuePair<string, object>> values)
{
if (values is Dictionary<string, object> dictionary)
{
return dictionary;
}
return values.ToDictionary(x => x.Key, x => x.Value);
}
}
}