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 +49
-0
lines changed
tests/ServiceStack.OrmLite.Tests Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -441,5 +441,54 @@ public void Does_CreateTableIfNotExists()
441
441
Assert . That ( rows [ 0 ] . Id , Is . EqualTo ( 1 ) ) ;
442
442
}
443
443
}
444
+
445
+ public class TableWithIgnoredFields
446
+ {
447
+ public int Id { get ; set ; }
448
+
449
+ public string FirstName { get ; set ; }
450
+
451
+ public string LastName { get ; set ; }
452
+
453
+ public string DisplayName
454
+ {
455
+ get { return FirstName + " " + LastName ; }
456
+ }
457
+
458
+ [ DataAnnotations . Ignore ]
459
+ public int IsIgnored { get ; set ; }
460
+
461
+ public Nested Nested { get ; set ; }
462
+ }
463
+
464
+ public class Nested
465
+ {
466
+ public string Name { get { return "Foo" ; } }
467
+ }
468
+
469
+ [ Test ]
470
+ public void Does_not_create_table_with_ignored_field ( )
471
+ {
472
+ using ( var db = OpenDbConnection ( ) )
473
+ {
474
+ db . DropAndCreateTable < TableWithIgnoredFields > ( ) ;
475
+
476
+ Assert . That ( db . GetLastSql ( ) , Is . StringContaining ( "DisplayName" ) ) ;
477
+ Assert . That ( db . GetLastSql ( ) , Is . Not . StringContaining ( "IsIgnored" ) ) ;
478
+
479
+ db . Insert ( new TableWithIgnoredFields
480
+ {
481
+ Id = 1 ,
482
+ FirstName = "Foo" ,
483
+ LastName = "Bar" ,
484
+ IsIgnored = 10 ,
485
+ } ) ;
486
+
487
+ var row = db . Select < TableWithIgnoredFields > ( ) [ 0 ] ;
488
+
489
+ Assert . That ( row . DisplayName , Is . EqualTo ( "Foo Bar" ) ) ;
490
+ Assert . That ( row . IsIgnored , Is . EqualTo ( 0 ) ) ;
491
+ }
492
+ }
444
493
}
445
494
}
You can’t perform that action at this time.
0 commit comments