@@ -7041,7 +7041,7 @@ public enum BusinessType18346
70417041 public virtual async Task Thread_safety_in_relational_command_cache ( )
70427042 {
70437043 var contextFactory = await InitializeAsync < MyContext21666 > (
7044- onConfiguring : options => ( ( IDbContextOptionsBuilderInfrastructure ) options ) . AddOrUpdateExtension (
7044+ onConfiguring : options => ( ( IDbContextOptionsBuilderInfrastructure ) options ) . AddOrUpdateExtension (
70457045 options . Options . FindExtension < SqlServerOptionsExtension > ( )
70467046 . WithConnection ( null )
70477047 . WithConnectionString ( SqlServerTestStore . CreateConnectionString ( StoreName ) ) ) ) ;
@@ -10345,6 +10345,59 @@ public class CollectionViewModel25225
1034510345
1034610346 #endregion
1034710347
10348+ #region Issue26742
10349+ [ ConditionalTheory ]
10350+ [ InlineData ( null , "" ) ]
10351+ //[InlineData(0, " (Scale = 0)")] //https://github.com/dotnet/SqlClient/issues/1380 prevents this passing, not EF
10352+ [ InlineData ( 1 , " (Scale = 1)" ) ]
10353+ [ InlineData ( 2 , " (Scale = 2)" ) ]
10354+ [ InlineData ( 3 , " (Scale = 3)" ) ]
10355+ [ InlineData ( 4 , " (Scale = 4)" ) ]
10356+ [ InlineData ( 5 , " (Scale = 5)" ) ]
10357+ [ InlineData ( 6 , " (Scale = 6)" ) ]
10358+ [ InlineData ( 7 , " (Scale = 7)" ) ]
10359+ public virtual async Task Query_generates_correct_datetime2_parameter_definition ( int ? fractionalSeconds , string postfix )
10360+ {
10361+ var contextFactory = await InitializeAsync < MyContext_26742 > ( onModelCreating : modelBuilder =>
10362+ {
10363+ if ( fractionalSeconds . HasValue )
10364+ {
10365+ modelBuilder . Entity < MyContext_26742 . Entity > ( ) . Property ( p => p . DateTime ) . HasPrecision ( fractionalSeconds . Value ) ;
10366+ }
10367+ } ) ;
10368+
10369+ var parameter = new DateTime ( 2021 , 11 , 12 , 13 , 14 , 15 ) . AddTicks ( 1234567 ) ;
10370+
10371+ using ( var context = contextFactory . CreateContext ( ) )
10372+ {
10373+ _ = context . Entities . FirstOrDefault ( x => x . DateTime == parameter ) ;
10374+
10375+ AssertSql (
10376+ $@ "@__parameter_0='2021-11-12T13:14:15.1234567'{ postfix }
10377+
10378+ SELECT TOP(1) [e].[Id], [e].[DateTime]
10379+ FROM [Entities] AS [e]
10380+ WHERE [e].[DateTime] = @__parameter_0" ) ;
10381+ }
10382+ }
10383+
10384+ protected class MyContext_26742 : DbContext
10385+ {
10386+ public DbSet < Entity > Entities { get ; set ; }
10387+
10388+ public MyContext_26742 ( DbContextOptions options )
10389+ : base ( options )
10390+ {
10391+ }
10392+
10393+ public class Entity
10394+ {
10395+ public int Id { get ; set ; }
10396+ public DateTime DateTime { get ; set ; }
10397+ }
10398+ }
10399+ #endregion
10400+
1034810401 protected override string StoreName => "QueryBugsTest" ;
1034910402 protected TestSqlLoggerFactory TestSqlLoggerFactory
1035010403 => ( TestSqlLoggerFactory ) ListLoggerFactory ;
0 commit comments