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 +40
-0
lines changed
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,46 @@ public void Can_InsertOnly_selected_fields_using_AssignmentExpression()
271
271
Assert . That ( row . LastName , Is . Null ) ;
272
272
}
273
273
}
274
+
275
+ [ Test ]
276
+ public void Can_insert_record_with_Computed_column ( )
277
+ {
278
+ using ( var db = OpenDbConnection ( ) )
279
+ {
280
+ db . DropAndCreateTable < Market > ( ) ;
281
+ var market = new Market
282
+ {
283
+ Available = 10 ,
284
+ AvailableTotal = 0 ,
285
+ AvailableSalesEvent = 2 ,
286
+ MinCustomerBuy = 10
287
+ } ;
288
+
289
+ var fieldDef = typeof ( Market ) . GetModelMetadata ( )
290
+ . GetFieldDefinition < Market > ( x => x . AvailableTotal ) ;
291
+
292
+ fieldDef . IsComputed = false ;
293
+
294
+ db . Insert ( market ) ;
295
+
296
+ fieldDef . IsComputed = true ;
297
+ }
298
+ }
299
+ }
300
+
301
+ public class Market
302
+ {
303
+ [ AutoIncrement ]
304
+ public int Id { get ; set ; }
305
+ [ Required ]
306
+ public int Available { get ; set ; }
307
+ [ Required ]
308
+ public int AvailableSalesEvent { get ; set ; }
309
+ [ Compute ]
310
+ [ Required ]
311
+ public int AvailableTotal { get ; set ; }
312
+ [ Required ]
313
+ public int ? MinCustomerBuy { get ; set ; }
274
314
}
275
315
276
316
public class UserAuth
You can’t perform that action at this time.
0 commit comments