Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 98f772b

Browse files
committed
Update README
1 parent 68839ed commit 98f772b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,48 @@ using (var db = OpenDbConnection())
777777
}
778778
```
779779

780+
### Replay Exec Filter
781+
782+
Or if you want to do things like executing each operation multiple times, e.g:
783+
784+
```csharp
785+
public class ReplayOrmLiteExecFilter : OrmLiteExecFilter
786+
{
787+
public int ReplayTimes { get; set; }
788+
789+
public override T Exec<T>(IDbConnection dbConn, Func<IDbCommand, T> filter)
790+
{
791+
var holdProvider = OrmLiteConfig.DialectProvider;
792+
var dbCmd = CreateCommand(dbConn);
793+
try
794+
{
795+
var ret = default(T);
796+
for (var i = 0; i < ReplayTimes; i++)
797+
{
798+
ret = filter(dbCmd);
799+
}
800+
return ret;
801+
}
802+
finally
803+
{
804+
DisposeCommand(dbCmd);
805+
OrmLiteConfig.DialectProvider = holdProvider;
806+
}
807+
}
808+
}
809+
810+
OrmLiteConfig.ExecFilter = new ReplayOrmLiteExecFilter { ReplayTimes = 3 };
811+
812+
using (var db = OpenDbConnection())
813+
{
814+
db.DropAndCreateTable<PocoTable>();
815+
db.Insert(new PocoTable { Name = "Multiplicity" });
816+
817+
var rowsInserted = db.Count<PocoTable>(q => q.Name == "Multiplicity"); //3
818+
}
819+
```
820+
821+
780822
## Mockable extension methods
781823

782824
The Result Filters also lets you easily mock results and avoid hitting the database, typically useful in Unit Testing Services to mock OrmLite API's directly instead of using a repository, e.g:

0 commit comments

Comments
 (0)