@@ -46,33 +46,32 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
4646 modelBuilder . HasDefaultSchema ( "invoice" ) ;
4747
4848 // You could manually set up the Query Filter, but there is an easier approach
49- //NOTE: used manually because NET8 changes the GetEntityTypes() type, which causes issues in unit tests
50- modelBuilder . Entity < Invoice > ( ) . HasQueryFilter ( x => x . DataKey == DataKey ) ;
51- modelBuilder . Entity < LineItem > ( ) . HasQueryFilter ( x => x . DataKey == DataKey ) ;
52- modelBuilder . Entity < CompanyTenant > ( ) . HasQueryFilter ( x => x . DataKey == DataKey ) ;
53- modelBuilder . Entity < LineItem > ( ) . Property ( x => x . TotalPrice ) . HasPrecision ( 9 , 2 ) ;
49+ //modelBuilder.Entity<Invoice>().HasQueryFilter(x => x.DataKey == DataKey);
50+ //modelBuilder.Entity<LineItem>().HasQueryFilter(x => x.DataKey == DataKey);
51+ //modelBuilder.Entity<CompanyTenant>().HasQueryFilter(x => x.DataKey == DataKey);
52+ //modelBuilder.Entity<LineItem>().Property(x => x.TotalPrice).HasPrecision(9, 2);
5453
55- // foreach (var entityType in modelBuilder.Model.GetEntityTypes())
56- // {
57- // if (typeof(IDataKeyFilterReadWrite).IsAssignableFrom(entityType.ClrType))
58- // {
59- // entityType.AddSingleTenantReadWriteQueryFilter(this);
60- // }
61- // else
62- // {
63- // throw new Exception(
64- // $"You haven't added the {nameof(IDataKeyFilterReadWrite)} to the entity {entityType.ClrType.Name}");
65- // }
54+ foreach ( var entityType in modelBuilder . Model . GetEntityTypes ( ) )
55+ {
56+ if ( typeof ( IDataKeyFilterReadWrite ) . IsAssignableFrom ( entityType . ClrType ) )
57+ {
58+ entityType . AddSingleTenantReadWriteQueryFilter ( this ) ;
59+ }
60+ else
61+ {
62+ throw new Exception (
63+ $ "You haven't added the { nameof ( IDataKeyFilterReadWrite ) } to the entity { entityType . ClrType . Name } ") ;
64+ }
6665
67- // foreach (var mutableProperty in entityType.GetProperties())
68- // {
69- // if (mutableProperty.ClrType == typeof(decimal))
70- // {
71- // mutableProperty.SetPrecision(9);
72- // mutableProperty.SetScale(2);
73- // }
74- // }
75- // }
66+ foreach ( var mutableProperty in entityType . GetProperties ( ) )
67+ {
68+ if ( mutableProperty . ClrType == typeof ( decimal ) )
69+ {
70+ mutableProperty . SetPrecision ( 9 ) ;
71+ mutableProperty . SetScale ( 2 ) ;
72+ }
73+ }
74+ }
7675 }
7776
7877
0 commit comments