提交 a46ab4e7 编写于 作者: N Nick Craver

Merge pull request #371 from janzakrzewskipl/master

fixed GetAll when used with ExplicitKey
...@@ -153,6 +153,19 @@ public void InsertGetUpdateDeleteWithExplicitKey() ...@@ -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() public void ShortIdentity()
{ {
using (var connection = GetOpenConnection()) using (var connection = GetOpenConnection())
......
...@@ -201,10 +201,11 @@ private static bool IsWriteable(PropertyInfo pi) ...@@ -201,10 +201,11 @@ private static bool IsWriteable(PropertyInfo pi)
if (!GetQueries.TryGetValue(cacheType.TypeHandle, out sql)) if (!GetQueries.TryGetValue(cacheType.TypeHandle, out sql))
{ {
var keys = KeyPropertiesCache(type); var keys = KeyPropertiesCache(type);
if (keys.Count() > 1) var explicitKeys = ExplicitKeyPropertiesCache(type);
throw new DataException("Get<T> only supports an entity with a single [Key] property"); if (keys.Count() > 1 || explicitKeys.Count() > 1)
if (!keys.Any()) throw new DataException("Get<T> only supports an entity with a single [Key] or [ExplicitKey] property");
throw new DataException("Get<T> only supports en entity with a [Key] 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); var name = GetTableName(type);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册