OpenSource » Database Migrator » Legacy Migrator
Clone URL:  

Migrator Convert column can now ignore cached conversions.

Changeset a29032a10991

Parent bae170f0e9c5

by jasoncline

Changes to 2 files · Browse files at a29032a10991 Showing diff from parent bae170f0e9c5 Diff from another changeset...

 
14
15
16
 
17
18
19
 
253
254
255
256
257
258
 
 
 
 
 
259
260
261
 
14
15
16
17
18
19
20
 
254
255
256
 
 
 
257
258
259
260
261
262
263
264
@@ -14,6 +14,7 @@
 using System.Data.SqlClient;  using System.Text;  using System.Globalization; +using System.Collections.Generic;    namespace Migrator.Providers  { @@ -253,9 +254,11 @@
  {   if (!(reader[column] is DBNull))   { - U value = convertFunc.Invoke((T)reader[column], reader); - if (!data.Contains(reader[column])) - data.Add(reader[column], value); + if (!this.CacheConvertedValues || !data.Contains(reader[column])) + { + U value = convertFunc.Invoke((T)reader[column], reader); + data[reader[column]] = value; + }   }   }   }
 
40
41
42
43
 
44
45
46
 
52
53
54
 
 
 
 
 
 
 
 
 
55
56
57
 
462
463
464
 
465
466
467
 
40
41
42
 
43
44
45
46
 
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
471
472
473
474
475
476
477
@@ -40,7 +40,7 @@
  protected IDbConnection _connection;   private IDbTransaction _transaction;   private String _assemblyId = null; - + private Boolean _cacheConvertedValues = true;   public delegate U ConvertColumnDelegate<T, U>(T currentValue, IDataReader row);     #region Properties @@ -52,6 +52,15 @@
  }   }   + /// <summary> + /// States weither to cache a conversion value or to invoke the conversion function every time. Defaults to cached. + /// </summary> + public Boolean CacheConvertedValues + { + get { return _cacheConvertedValues; } + set { _cacheConvertedValues = value; } + } +   public IDbConnection Connection   {   get { return _connection; } @@ -462,6 +471,7 @@
  public int ParameterizedNonQuery(string commandText, Dictionary<String, Object> parameters)   {   IDbCommand cmd = BuildCommand(commandText); + cmd.Prepare();   foreach (String key in parameters.Keys)   {   Object value = parameters[key];