This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-12
lines changed
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -1992,14 +1992,12 @@ public interface IAudit
1992
1992
}
1993
1993
1994
1994
OrmLiteConfig .InsertFilter = (dbCmd , row ) => {
1995
- var auditRow = row as IAudit ;
1996
- if (auditRow != null )
1995
+ if (row is IAudit auditRow )
1997
1996
auditRow .CreatedDate = auditRow .ModifiedDate = DateTime .UtcNow ;
1998
1997
};
1999
1998
2000
1999
OrmLiteConfig .UpdateFilter = (dbCmd , row ) => {
2001
- var auditRow = row as IAudit ;
2002
- if (auditRow != null )
2000
+ if (row is IAudit auditRow )
2003
2001
auditRow .ModifiedDate = DateTime .UtcNow ;
2004
2002
};
2005
2003
```
@@ -2012,8 +2010,7 @@ The filters can also be used for validation where throwing an exception will pre
2012
2010
2013
2011
``` csharp
2014
2012
OrmLiteConfig .InsertFilter = OrmLiteConfig .UpdateFilter = (dbCmd , row ) => {
2015
- var auditRow = row as IAudit ;
2016
- if (auditRow != null && auditRow .ModifiedBy == null )
2013
+ if (row is IAudit auditRow && auditRow .ModifiedBy == null )
2017
2014
throw new ArgumentNullException (" ModifiedBy" );
2018
2015
};
2019
2016
Original file line number Diff line number Diff line change @@ -97,17 +97,15 @@ public void Does_call_Filters_on_Save()
97
97
98
98
OrmLiteConfig . InsertFilter = ( dbCmd , row ) =>
99
99
{
100
- var auditRow = row as IAudit ;
101
- if ( auditRow != null )
100
+ if ( row is IAudit auditRow )
102
101
{
103
102
auditRow . CreatedDate = auditRow . ModifiedDate = insertDate ;
104
103
}
105
104
} ;
106
105
107
106
OrmLiteConfig . UpdateFilter = ( dbCmd , row ) =>
108
107
{
109
- var auditRow = row as IAudit ;
110
- if ( auditRow != null )
108
+ if ( row is IAudit auditRow )
111
109
{
112
110
auditRow . ModifiedDate = updateDate ;
113
111
}
@@ -147,8 +145,7 @@ public void Exceptions_in_filters_prevents_insert_and_update()
147
145
{
148
146
OrmLiteConfig . InsertFilter = OrmLiteConfig . UpdateFilter = ( dbCmd , row ) =>
149
147
{
150
- var auditRow = row as IAudit ;
151
- if ( auditRow != null )
148
+ if ( row is IAudit auditRow )
152
149
{
153
150
if ( auditRow . ModifiedBy == null )
154
151
throw new ArgumentNullException ( "ModifiedBy" ) ;
You can’t perform that action at this time.
0 commit comments