Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
a8287501
Commit
a8287501
authored
Oct 29, 2011
by
marc.gravell@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guid fix; IMPORTANT
parent
b55cc9a4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
19 deletions
+51
-19
SqlMapper.cs
Dapper/SqlMapper.cs
+2
-1
DapperTests.csproj
Tests/DapperTests.csproj
+1
-0
SqlMapper.EntityFramework.tempdbEntities1.datasource
...rces/SqlMapper.EntityFramework.tempdbEntities1.datasource
+10
-0
Tests.cs
Tests/Tests.cs
+38
-18
No files found.
Dapper/SqlMapper.cs
View file @
a8287501
...
...
@@ -928,7 +928,8 @@ private static CacheInfo GetCacheInfo(Identity identity)
if
(
(
type
.
IsClass
&&
type
!=
typeof
(
string
)
&&
type
!=
typeof
(
byte
[])
&&
type
!=
typeof
(
System
.
Data
.
Linq
.
Binary
))
||
(
type
.
IsValueType
&&
!
type
.
IsPrimitive
&&
!(
type
.
IsGenericType
&&
type
.
GetGenericTypeDefinition
()
==
typeof
(
Nullable
<>)))
(
type
.
IsValueType
&&
!
type
.
IsPrimitive
&&
!(
type
.
IsGenericType
&&
type
.
GetGenericTypeDefinition
()
==
typeof
(
Nullable
<>))
&&
type
!=
typeof
(
Guid
))
)
{
return
GetTypeDeserializer
(
type
,
reader
,
startBound
,
length
,
returnNullIfFirstMissing
);
...
...
Tests/DapperTests.csproj
View file @
a8287501
...
...
@@ -184,6 +184,7 @@
<SubType>
Designer
</SubType>
</None>
<None
Include=
"packages.config"
/>
<None
Include=
"Properties\DataSources\SqlMapper.EntityFramework.tempdbEntities1.datasource"
/>
<None
Include=
"Properties\Settings.settings"
>
<Generator>
SettingsSingleFileGenerator
</Generator>
<LastGenOutput>
Settings.Designer.cs
</LastGenOutput>
...
...
Tests/Properties/DataSources/SqlMapper.EntityFramework.tempdbEntities1.datasource
0 → 100644
View file @
a8287501
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource
DisplayName=
"tempdbEntities1"
Identifier=
"SqlMapper.EntityFramework.tempdbEntities1"
ProviderType=
"Microsoft.VisualStudio.DataDesign.DataSourceProviders.EntityDataModel.EdmDataSourceProvider"
Version=
"1.0"
xmlns=
"urn:schemas-microsoft-com:xml-msdatasource"
>
<TypeInfo>
SqlMapper.EntityFramework.tempdbEntities1, EntityFramework.Model.Designer.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
</TypeInfo>
</GenericObjectDataSource>
\ No newline at end of file
Tests/Tests.cs
View file @
a8287501
...
...
@@ -45,7 +45,7 @@ public void SelectListInt()
}
public
void
SelectBinary
()
{
connection
.
Query
<
byte
[
]>
(
"select cast(1 as varbinary(4))"
).
First
().
SequenceEqual
(
new
byte
[]
{
1
});
connection
.
Query
<
byte
[
]>
(
"select cast(1 as varbinary(4))"
).
First
().
SequenceEqual
(
new
byte
[]
{
1
});
}
public
void
PassInIntArray
()
{
...
...
@@ -75,7 +75,7 @@ public void TestSchemaChanged()
public
void
TestSchemaChangedMultiMap
()
{
connection
.
Execute
(
"create table #dog(Age int, Name nvarchar(max)) insert #dog values(1, 'Alf')"
);
var
tuple
=
connection
.
Query
<
Dog
,
Dog
,
Tuple
<
Dog
,
Dog
>>(
"select * from #dog d1 join #dog d2 on 1=1"
,
(
d1
,
d2
)
=>
Tuple
.
Create
(
d1
,
d2
),
splitOn
:
"Age"
).
Single
();
var
tuple
=
connection
.
Query
<
Dog
,
Dog
,
Tuple
<
Dog
,
Dog
>>(
"select * from #dog d1 join #dog d2 on 1=1"
,
(
d1
,
d2
)
=>
Tuple
.
Create
(
d1
,
d2
),
splitOn
:
"Age"
).
Single
();
tuple
.
Item1
.
Name
.
IsEqualTo
(
"Alf"
);
tuple
.
Item1
.
Age
.
IsEqualTo
(
1
);
...
...
@@ -83,7 +83,7 @@ public void TestSchemaChangedMultiMap()
tuple
.
Item2
.
Age
.
IsEqualTo
(
1
);
connection
.
Execute
(
"alter table #dog drop column Name"
);
tuple
=
connection
.
Query
<
Dog
,
Dog
,
Tuple
<
Dog
,
Dog
>>(
"select * from #dog d1 join #dog d2 on 1=1"
,
(
d1
,
d2
)
=>
Tuple
.
Create
(
d1
,
d2
),
splitOn
:
"Age"
).
Single
();
tuple
=
connection
.
Query
<
Dog
,
Dog
,
Tuple
<
Dog
,
Dog
>>(
"select * from #dog d1 join #dog d2 on 1=1"
,
(
d1
,
d2
)
=>
Tuple
.
Create
(
d1
,
d2
),
splitOn
:
"Age"
).
Single
();
tuple
.
Item1
.
Name
.
IsNull
();
tuple
.
Item1
.
Age
.
IsEqualTo
(
1
);
...
...
@@ -240,7 +240,7 @@ public void TestExecuteMultipleCommand()
class
Student
{
public
string
Name
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
int
Age
{
get
;
set
;
}
}
...
...
@@ -345,7 +345,7 @@ public void TestEnumerationDynamic()
public
void
TestNakedBigInt
()
{
long
foo
=
12345
;
var
result
=
connection
.
Query
<
long
>(
"select @foo"
,
new
{
foo
}).
Single
();
var
result
=
connection
.
Query
<
long
>(
"select @foo"
,
new
{
foo
}).
Single
();
foo
.
IsEqualTo
(
result
);
}
...
...
@@ -355,7 +355,7 @@ public void TestBigIntMember()
var
result
=
connection
.
Query
<
WithBigInt
>(
@"
declare @bar table(Value bigint)
insert @bar values (@foo)
select * from @bar"
,
new
{
foo
}).
Single
();
select * from @bar"
,
new
{
foo
}).
Single
();
result
.
Value
.
IsEqualTo
(
foo
);
}
class
WithBigInt
...
...
@@ -937,10 +937,12 @@ class WithBizarreData
public
void
TestUnexpectedDataMessage
()
{
string
msg
=
null
;
try
{
try
{
connection
.
Query
<
int
>(
"select count(1) where 1 = @Foo"
,
new
WithBizarreData
{
Foo
=
new
GenericUriParser
(
GenericUriParserOptions
.
Default
),
Bar
=
23
}).
First
();
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
msg
=
ex
.
Message
;
}
...
...
@@ -1064,7 +1066,7 @@ public void TestDynamicParamNullSupport()
var
p
=
new
DynamicParameters
();
p
.
Add
(
"@b"
,
dbType
:
DbType
.
Int32
,
direction
:
ParameterDirection
.
Output
);
connection
.
Execute
(
"select @b = null"
,
p
);
connection
.
Execute
(
"select @b = null"
,
p
);
p
.
Get
<
int
?>(
"@b"
).
IsNull
();
}
...
...
@@ -1144,7 +1146,7 @@ public void TestAppendingAnonClasses()
public
void
TestAppendingAList
()
{
DynamicParameters
p
=
new
DynamicParameters
();
var
list
=
new
int
[]
{
1
,
2
,
3
};
var
list
=
new
int
[]
{
1
,
2
,
3
};
p
.
AddDynamicParams
(
new
{
list
});
var
result
=
connection
.
Query
<
int
>(
"select * from (select 1 A union all select 2 union all select 3) X where A in @list"
,
p
).
ToList
();
...
...
@@ -1154,5 +1156,23 @@ public void TestAppendingAList()
result
[
2
].
IsEqualTo
(
3
);
}
public
void
TestUniqueIdentifier
()
{
var
guid
=
Guid
.
NewGuid
();
var
result
=
connection
.
Query
<
Guid
>(
"declare @foo uniqueidentifier set @foo = @guid select @foo"
,
new
{
guid
}).
Single
();
result
.
IsEqualTo
(
guid
);
}
public
void
TestNullableUniqueIdentifierNonNull
()
{
Guid
?
guid
=
Guid
.
NewGuid
();
var
result
=
connection
.
Query
<
Guid
?>(
"declare @foo uniqueidentifier set @foo = @guid select @foo"
,
new
{
guid
}).
Single
();
result
.
IsEqualTo
(
guid
);
}
public
void
TestNullableUniqueIdentifierNull
()
{
Guid
?
guid
=
null
;
var
result
=
connection
.
Query
<
Guid
?>(
"declare @foo uniqueidentifier set @foo = @guid select @foo"
,
new
{
guid
}).
Single
();
result
.
IsEqualTo
(
guid
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment