以下未经测试
private List GetDeleteList(List keys)
{
var theProperty = GetKeyPropertys(typeof(T)).FirstOrDefault();
if (theProperty == null)
throw new Exception("该实体没有主键标识!请使用[Key]标识主键!");
List<T> deleteList = new List<T>();
keys.ForEach(aKey =>
{
T newData = Activator.CreateInstance<T>();
var value = Convert.ChangeType(aKey, theProperty.PropertyType);
theProperty.SetValue(newData, value);
deleteList.Add(newData);
});
return deleteList;
在DefaultDbAccessor类中,根据主键批量删除方法,GetDeleteList返回的是object集合导致报错,应该返回T泛型集合
以下未经测试 private List GetDeleteList(List keys)
{
var theProperty = GetKeyPropertys(typeof(T)).FirstOrDefault();
if (theProperty == null)
throw new Exception("该实体没有主键标识!请使用[Key]标识主键!");
}