@@ -45,32 +45,34 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
4545 {
4646 modelBuilder . HasDefaultSchema ( "invoice" ) ;
4747
48- // You could manually set up the Query Filter, but there is a easier approach
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);
48+ // 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 ) ;
5254
53- foreach ( var entityType in modelBuilder . Model . GetEntityTypes ( ) )
54- {
55- if ( typeof ( IDataKeyFilterReadWrite ) . IsAssignableFrom ( entityType . ClrType ) )
56- {
57- entityType . AddSingleTenantReadWriteQueryFilter ( this ) ;
58- }
59- else
60- {
61- throw new Exception (
62- $ "You haven't added the { nameof ( IDataKeyFilterReadWrite ) } to the entity { entityType . ClrType . Name } ") ;
63- }
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+ // }
6466
65- foreach ( var mutableProperty in entityType . GetProperties ( ) )
66- {
67- if ( mutableProperty . ClrType == typeof ( decimal ) )
68- {
69- mutableProperty . SetPrecision ( 9 ) ;
70- mutableProperty . SetScale ( 2 ) ;
71- }
72- }
73- }
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+ // }
7476 }
7577
7678
0 commit comments