void Remap(SaveResult result) { result.Entities = result.Entities.Select(o => { var treeTop = MapperConfig.GetToDtoLambda(MapperConfig.GetDtoType(o.GetType()), _currentUser); //possibly Assert(treeTop.WhereExpression.Compile().DynamicInvoke(o);) //possible bottleneck - could cast to all the different types return(treeTop.SelectExpression.Compile().DynamicInvoke(o)); }).ToList(); foreach (var k in result.DeletedKeys) { k.EntityTypeName = k.EntityTypeName.Replace(":#SP.DataAccess", "Dto:#SP.Dto"); } }