Mapper BUG

This commit is contained in:
sunkaixuan 2019-05-16 12:54:24 +08:00
parent 80f9db103e
commit 4dd0c2e729
2 changed files with 9 additions and 1 deletions

View File

@ -1185,6 +1185,7 @@ namespace SqlSugar
var mapperCache = new MapperCache<T>(list, this.Context);
foreach (T item in list)
{
mapperCache.GetIndex = 0;
this.MapperActionWithCache(item, mapperCache);
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace SqlSugar
@ -10,6 +11,7 @@ namespace SqlSugar
private Dictionary<string, object> caches = new Dictionary<string, object>();
private List<T> _list { get; set; }
private ISqlSugarClient _context { get; set; }
public int GetIndex { get; set; }
private MapperCache()
{
}
@ -20,7 +22,8 @@ namespace SqlSugar
}
public Result Get<Result>(Func<List<T>, Result> action)
{
string key = "Get" + typeof(Result) + action.GetHashCode().ToString();
GetIndex++;
string key = "Get" + GetIndex;
if (caches.ContainsKey(key))
{
return (Result)caches[key];
@ -32,6 +35,10 @@ namespace SqlSugar
return result;
}
}
private static Expression<Func<List<T>, Result>> FuncToExpression<Result>(Func<List<T>, Result> f)
{
return x => f(x);
}
public List<Result> GetListByPrimaryKeys<Result>(Func<T, double?> action) where Result : class, new()
{
{