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
b6cbb98a
Commit
b6cbb98a
authored
Dec 07, 2015
by
Nick Craver
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pr/420'
parents
69b63884
b0cd0ef8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
SqlMapperExtensions.cs
Dapper.Contrib/SqlMapperExtensions.cs
+2
-2
TestSuite.cs
Dapper.Tests.Contrib/TestSuite.cs
+34
-3
No files found.
Dapper.Contrib/SqlMapperExtensions.cs
View file @
b6cbb98a
...
@@ -368,7 +368,7 @@ private static string GetTableName(Type type)
...
@@ -368,7 +368,7 @@ private static string GetTableName(Type type)
if
(
type
.
IsArray
||
type
.
IsGenericType
())
if
(
type
.
IsArray
||
type
.
IsGenericType
())
type
=
type
.
GetGenericArguments
()[
0
];
type
=
type
.
GetGenericArguments
()[
0
];
var
keyProperties
=
KeyPropertiesCache
(
type
)
;
var
keyProperties
=
KeyPropertiesCache
(
type
)
.
ToList
();
//added ToList() due to issue #418, must work on a list copy
var
explicitKeyProperties
=
ExplicitKeyPropertiesCache
(
type
);
var
explicitKeyProperties
=
ExplicitKeyPropertiesCache
(
type
);
if
(!
keyProperties
.
Any
()
&&
!
explicitKeyProperties
.
Any
())
if
(!
keyProperties
.
Any
()
&&
!
explicitKeyProperties
.
Any
())
throw
new
ArgumentException
(
"Entity must have at least one [Key] or [ExplicitKey] property"
);
throw
new
ArgumentException
(
"Entity must have at least one [Key] or [ExplicitKey] property"
);
...
@@ -423,7 +423,7 @@ private static string GetTableName(Type type)
...
@@ -423,7 +423,7 @@ private static string GetTableName(Type type)
if
(
type
.
IsArray
||
type
.
IsGenericType
())
if
(
type
.
IsArray
||
type
.
IsGenericType
())
type
=
type
.
GetGenericArguments
()[
0
];
type
=
type
.
GetGenericArguments
()[
0
];
var
keyProperties
=
KeyPropertiesCache
(
type
)
;
var
keyProperties
=
KeyPropertiesCache
(
type
)
.
ToList
();
//added ToList() due to issue #418, must work on a list copy
var
explicitKeyProperties
=
ExplicitKeyPropertiesCache
(
type
);
var
explicitKeyProperties
=
ExplicitKeyPropertiesCache
(
type
);
if
(!
keyProperties
.
Any
()
&&
!
explicitKeyProperties
.
Any
())
if
(!
keyProperties
.
Any
()
&&
!
explicitKeyProperties
.
Any
())
throw
new
ArgumentException
(
"Entity must have at least one [Key] or [ExplicitKey] property"
);
throw
new
ArgumentException
(
"Entity must have at least one [Key] or [ExplicitKey] property"
);
...
...
Dapper.Tests.Contrib/TestSuite.cs
View file @
b6cbb98a
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
using
System.Linq
;
using
System.Linq
;
using
Dapper.Contrib.Extensions
;
using
Dapper.Contrib.Extensions
;
using
Xunit
;
#if COREFX
#if COREFX
using
System.Reflection
;
using
System.Reflection
;
...
@@ -15,6 +14,8 @@
...
@@ -15,6 +14,8 @@
#endif
#endif
#if XUNIT2
#if XUNIT2
using
FactAttribute
=
Dapper
.
Tests
.
Contrib
.
SkippableFactAttribute
;
using
FactAttribute
=
Dapper
.
Tests
.
Contrib
.
SkippableFactAttribute
;
#else
using
Xunit
;
#endif
#endif
namespace
Dapper.Tests.Contrib
namespace
Dapper.Tests.Contrib
...
@@ -101,6 +102,35 @@ private IDbConnection GetOpenConnection()
...
@@ -101,6 +102,35 @@ private IDbConnection GetOpenConnection()
return
connection
;
return
connection
;
}
}
[
Fact
]
public
void
Issue418
()
{
using
(
var
connection
=
GetOpenConnection
())
{
//update first (will fail) then insert
//added for bug #418
var
updateObject
=
new
ObjectX
{
ObjectXId
=
Guid
.
NewGuid
().
ToString
(),
Name
=
"Someone"
};
var
updates
=
connection
.
Update
(
updateObject
);
updates
.
IsFalse
();
connection
.
DeleteAll
<
ObjectX
>();
var
objectXId
=
Guid
.
NewGuid
().
ToString
();
var
insertObject
=
new
ObjectX
{
ObjectXId
=
objectXId
,
Name
=
"Someone else"
};
connection
.
Insert
(
insertObject
);
var
list
=
connection
.
GetAll
<
ObjectX
>();
list
.
Count
().
IsEqualTo
(
1
);
}
}
/// <summary>
/// <summary>
/// Tests for issue #351
/// Tests for issue #351
/// </summary>
/// </summary>
...
@@ -152,8 +182,9 @@ public void GetAllWithExplicitKey()
...
@@ -152,8 +182,9 @@ public void GetAllWithExplicitKey()
var
o1
=
new
ObjectX
{
ObjectXId
=
guid
,
Name
=
"Foo"
};
var
o1
=
new
ObjectX
{
ObjectXId
=
guid
,
Name
=
"Foo"
};
connection
.
Insert
(
o1
);
connection
.
Insert
(
o1
);
var
objectXs
=
connection
.
GetAll
<
ObjectX
>();
var
objectXs
=
connection
.
GetAll
<
ObjectX
>().
ToList
();
objectXs
.
Count
().
IsEqualTo
(
1
);
objectXs
.
Count
.
IsMoreThan
(
0
);
objectXs
.
Count
(
x
=>
x
.
ObjectXId
==
guid
).
IsEqualTo
(
1
);
}
}
}
}
...
...
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