Commit a46ab4e7 authored by Nick Craver's avatar Nick Craver

Merge pull request #371 from janzakrzewskipl/master

fixed GetAll when used with ExplicitKey
parents 45df8d8d e447523d
......@@ -153,6 +153,19 @@ public void InsertGetUpdateDeleteWithExplicitKey()
}
}
public void GetAllWithExplicitKey()
{
using (var connection = GetOpenConnection())
{
var guid = Guid.NewGuid().ToString();
var o1 = new ObjectX { ObjectXId = guid, Name = "Foo" };
connection.Insert(o1);
var objectXs = connection.GetAll<ObjectX>();
objectXs.Count().IsEqualTo(1);
}
}
public void ShortIdentity()
{
using (var connection = GetOpenConnection())
......
......@@ -201,10 +201,11 @@ private static bool IsWriteable(PropertyInfo pi)
if (!GetQueries.TryGetValue(cacheType.TypeHandle, out sql))
{
var keys = KeyPropertiesCache(type);
if (keys.Count() > 1)
throw new DataException("Get<T> only supports an entity with a single [Key] property");
if (!keys.Any())
throw new DataException("Get<T> only supports en entity with a [Key] property");
var explicitKeys = ExplicitKeyPropertiesCache(type);
if (keys.Count() > 1 || explicitKeys.Count() > 1)
throw new DataException("Get<T> only supports an entity with a single [Key] or [ExplicitKey] property");
if (!keys.Any() && !explicitKeys.Any())
throw new DataException("Get<T> only supports an entity with a [Key] or an [ExplicitKey] property");
var name = GetTableName(type);
......
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