FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Dapper/Dapper/SqlMapper.DapperTable.cs at dynamicparameters-apply · DapperLib/Dapper · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DapperLib
/
Dapper
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
3.7k
Star
18.4k
Code
Issues
463
Pull requests
83
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Dapper
/
Dapper
/
SqlMapper.DapperTable.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (41 loc) · 1.9 KB
Breadcrumbs
Dapper
/
Dapper
/
SqlMapper.DapperTable.cs
Copy path
File metadata and controls
49 lines (41 loc) · 1.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
using
System
;
using
System
.
Collections
.
Generic
;
namespace
Dapper
{
public
static
partial
class
SqlMapper
{
private
sealed
class
DapperTable
{
private
string
[
]
fieldNames
;
private
readonly
Dictionary
<
string
,
int
>
fieldNameLookup
;
internal
string
[
]
FieldNames
=>
fieldNames
;
public
DapperTable
(
string
[
]
fieldNames
)
{
this
.
fieldNames
=
fieldNames
??
throw
new
ArgumentNullException
(
nameof
(
fieldNames
)
)
;
fieldNameLookup
=
new
Dictionary
<
string
,
int
>
(
fieldNames
.
Length
,
StringComparer
.
Ordinal
)
;
// if there are dups, we want the **first** key to be the "winner" - so iterate backwards
for
(
int
i
=
fieldNames
.
Length
-
1
;
i
>=
0
;
i
--
)
{
string
key
=
fieldNames
[
i
]
;
if
(
key
is
not
null
)
fieldNameLookup
[
key
]
=
i
;
}
}
internal
int
IndexOfName
(
string
name
)
{
return
(
name
is
not
null
&&
fieldNameLookup
.
TryGetValue
(
name
,
out
int
result
)
)
?
result
:
-
1
;
}
internal
int
AddField
(
string
name
)
{
if
(
name
is
null
)
throw
new
ArgumentNullException
(
nameof
(
name
)
)
;
if
(
fieldNameLookup
.
ContainsKey
(
name
)
)
throw
new
InvalidOperationException
(
"Field already exists: "
+
name
)
;
int
oldLen
=
fieldNames
.
Length
;
Array
.
Resize
(
ref
fieldNames
,
oldLen
+
1
)
;
// yes, this is sub-optimal, but this is not the expected common case
fieldNames
[
oldLen
]
=
name
;
fieldNameLookup
[
name
]
=
oldLen
;
return
oldLen
;
}
internal
bool
FieldExists
(
string
key
)
=>
key
is
not
null
&&
fieldNameLookup
.
ContainsKey
(
key
)
;
public
int
FieldCount
=>
fieldNames
.
Length
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL