Created
January 23, 2012 21:57
-
-
Save Molokai/1665747 to your computer and use it in GitHub Desktop.
Quick and dirty implementation of transaction support for InMemoryAdapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Simple.Data; | |
namespace sykkelbooking.service.tests { | |
public class InMemoryAdapterWithShimTransactions: InMemoryAdapter, IAdapterWithTransactions, IAdapterTransaction { | |
public IAdapterTransaction BeginTransaction() { | |
return this; | |
} | |
public IAdapterTransaction BeginTransaction(string name) { | |
return this; | |
} | |
public IEnumerable<IDictionary<string, object>> Find(string tableName, SimpleExpression criteria, IAdapterTransaction transaction) { | |
return Find(tableName, criteria); | |
} | |
public IDictionary<string, object> Insert(string tableName, IDictionary<string, object> data, IAdapterTransaction transaction, bool resultRequired) { | |
return Insert(tableName, data, resultRequired); | |
} | |
public IEnumerable<IDictionary<string, object>> InsertMany(string tableName, IEnumerable<IDictionary<string, object>> data, IAdapterTransaction transaction, Func<IDictionary<string, object>, Exception, bool> onError, bool resultRequired) { | |
return | |
InsertMany(tableName, data, (dict, exception) => onError(new SimpleRecord(dict), exception), resultRequired); | |
} | |
public int Update(string tableName, IDictionary<string, object> data, SimpleExpression criteria, IAdapterTransaction transaction) { | |
return Update(tableName, data, criteria); | |
} | |
public int Delete(string tableName, SimpleExpression criteria, IAdapterTransaction transaction) { | |
return Delete(tableName, criteria); | |
} | |
public int UpdateMany(string tableName, IEnumerable<IDictionary<string, object>> dataList, IAdapterTransaction adapterTransaction) { | |
return UpdateMany(tableName, dataList); | |
} | |
public int UpdateMany(string tableName, IEnumerable<IDictionary<string, object>> dataList, IAdapterTransaction adapterTransaction, IList<string> keyFields) { | |
return UpdateMany(tableName, dataList, keyFields); | |
} | |
public int Update(string tableName, IDictionary<string, object> data, IAdapterTransaction adapterTransaction) { | |
return Update(tableName, data); | |
} | |
public int UpdateMany(string tableName, IList<IDictionary<string, object>> dataList, IEnumerable<string> criteriaFieldNames, IAdapterTransaction adapterTransaction) { | |
return UpdateMany(tableName, dataList, criteriaFieldNames); | |
} | |
public void Dispose() { | |
} | |
public void Commit() { | |
} | |
public void Rollback() { | |
} | |
public string Name { | |
get { throw new NotImplementedException(); } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment