This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
src/ServiceStack.OrmLite.Oracle Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,35 @@ public override void OnAfterInitColumnTypeMap()
107
107
}
108
108
109
109
protected string ClientProvider = OdpProvider ;
110
+ public static string RowVersionTriggerFormat = "{0}RowVersionUpdateTrigger" ;
111
+
112
+ public override string ToPostDropTableStatement ( ModelDefinition modelDef )
113
+ {
114
+ if ( modelDef . RowVersion != null )
115
+ {
116
+ var triggerName = RowVersionTriggerFormat . Fmt ( modelDef . ModelName ) ;
117
+ return "DROP TRIGGER IF EXISTS {0}" . Fmt ( GetQuotedTableName ( triggerName ) ) ;
118
+ }
119
+
120
+ return null ;
121
+ }
122
+
123
+ public override string ToPostCreateTableStatement ( ModelDefinition modelDef )
124
+ {
125
+ if ( modelDef . RowVersion != null )
126
+ {
127
+ var triggerName = RowVersionTriggerFormat . Fmt ( modelDef . ModelName ) ;
128
+ var triggerBody = ":NEW.{0} := :OLD.{0}+1;" . Fmt (
129
+ modelDef . RowVersion . FieldName . SqlColumn ( ) ) ;
130
+
131
+ var sql = "CREATE TRIGGER {0} BEFORE UPDATE ON {1} FOR EACH ROW BEGIN {2} END;" . Fmt (
132
+ triggerName , modelDef . ModelName , triggerBody ) ;
133
+
134
+ return sql ;
135
+ }
136
+
137
+ return null ;
138
+ }
110
139
111
140
public override IDbConnection CreateConnection ( string connectionString , Dictionary < string , string > options )
112
141
{
You can’t perform that action at this time.
0 commit comments