Commit 5c5eae8e authored by Johan Danforth's avatar Johan Danforth

Fix and test for issue #418

parent 69b63884
......@@ -368,7 +368,7 @@ private static string GetTableName(Type type)
if (type.IsArray || type.IsGenericType())
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);
if (!keyProperties.Any() && !explicitKeyProperties.Any())
throw new ArgumentException("Entity must have at least one [Key] or [ExplicitKey] property");
......@@ -423,7 +423,7 @@ private static string GetTableName(Type type)
if (type.IsArray || type.IsGenericType())
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);
if (!keyProperties.Any() && !explicitKeyProperties.Any())
throw new ArgumentException("Entity must have at least one [Key] or [ExplicitKey] property");
......
......@@ -101,6 +101,35 @@ private IDbConnection GetOpenConnection()
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"
};
var inserts = connection.Insert(insertObject);
var list = connection.GetAll<ObjectX>();
list.Count().IsEqualTo(1);
}
}
/// <summary>
/// Tests for issue #351
/// </summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment