-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKustoDbParameterCollection.cs
113 lines (93 loc) · 2.93 KB
/
KustoDbParameterCollection.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Common;
namespace EFCore.Azure.Kusto
{
public class KustoDbParameterCollection : DbParameterCollection
{
private readonly List<DbParameter> _parameters = new List<DbParameter>();
public override int Count => _parameters.Count;
public override object SyncRoot => ((ICollection)_parameters).SyncRoot;
public override int Add(object value)
{
_parameters.Add((DbParameter)value);
return _parameters.Count - 1;
}
public override void AddRange(Array values)
{
foreach (var value in values)
{
_parameters.Add((DbParameter)value);
}
}
public override void Clear()
{
_parameters.Clear();
}
public override bool Contains(object value)
{
return _parameters.Contains((DbParameter)value);
}
public override bool Contains(string value)
{
return _parameters.Exists(p => p.ParameterName == value);
}
public override void CopyTo(Array array, int index)
{
((ICollection)_parameters).CopyTo(array, index);
}
public override IEnumerator GetEnumerator()
{
return _parameters.GetEnumerator();
}
public override int IndexOf(object value)
{
return _parameters.IndexOf((DbParameter)value);
}
public override int IndexOf(string parameterName)
{
return _parameters.FindIndex(p => p.ParameterName == parameterName);
}
public override void Insert(int index, object value)
{
_parameters.Insert(index, (DbParameter)value);
}
public override void Remove(object value)
{
_parameters.Remove((DbParameter)value);
}
public override void RemoveAt(int index)
{
_parameters.RemoveAt(index);
}
public override void RemoveAt(string parameterName)
{
var index = IndexOf(parameterName);
if (index >= 0)
{
_parameters.RemoveAt(index);
}
}
protected override DbParameter GetParameter(int index)
{
return _parameters[index];
}
protected override DbParameter GetParameter(string parameterName)
{
return _parameters.Find(p => p.ParameterName == parameterName);
}
protected override void SetParameter(int index, DbParameter value)
{
_parameters[index] = value;
}
protected override void SetParameter(string parameterName, DbParameter value)
{
var index = IndexOf(parameterName);
if (index >= 0)
{
_parameters[index] = value;
}
}
}
}