You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It currently isn't possible to specify a value-converted type as a parameter in raw SQL. It seems like the pre-convention configuration DefaultTypeMapping should make this work:
Unhandled exception. System.InvalidOperationException: The current provider doesn't have a store type mapping for properties of type 'NameWrapper'.
at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSourceExtensions.GetMapping(IRelationalTypeMappingSource typeMappingSource, Type clrType) in /home/roji/projects/efcore/src/EFCore.Relational/Storage/RelationalTypeMappingSourceExtensions.cs:line 89
at Microsoft.EntityFrameworkCore.Storage.Internal.RawSqlCommandBuilder.Build(String sql, IEnumerable`1 parameters) in /home/roji/projects/efcore/src/EFCore.Relational/Storage/Internal/RawSqlCommandBuilder.cs:line 83
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, IEnumerable`1 parameters) in /home/roji/projects/efcore/src/EFCore.Relational/Extensions/RelationalDatabaseFacadeExtensions.cs:line 244
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, Object[] parameters) in /home/roji/projects/efcore/src/EFCore.Relational/Extensions/RelationalDatabaseFacadeExtensions.cs:line 159
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlInterpolated(DatabaseFacade databaseFacade, FormattableString sql) in /home/roji/projects/efcore/src/EFCore.Relational/Extensions/RelationalDatabaseFacadeExtensions.cs:line 191
Full repro
awaitusingvarctx=newBlogContext();awaitctx.Database.EnsureDeletedAsync();awaitctx.Database.EnsureCreatedAsync();ctx.Database.ExecuteSqlInterpolated($@"SELECT * FROM ""Blogs"" WHERE ""Name"" = {newNameWrapper{Name="foo "}}");publicclassBlogContext:DbContext{publicDbSet<Blog>Blogs{get;set;}protectedoverridevoidOnConfiguring(DbContextOptionsBuilderoptionsBuilder)=>optionsBuilder.UseSqlServer(@"Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0").LogTo(Console.WriteLine,LogLevel.Information).EnableSensitiveDataLogging();protectedoverridevoidConfigureConventions(ModelConfigurationBuilderconfigurationBuilder){configurationBuilder.DefaultTypeMapping<NameWrapper>().HasConversion(typeof(NameWrapperConverter));}protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder){modelBuilder.Entity<Blog>().Property(b =>b.Name).HasConversion(typeof(NameWrapperConverter));}classNameWrapperConverter:ValueConverter<NameWrapper,string>{publicNameWrapperConverter():base(nw =>nw.Name, s =>newNameWrapper{Name=s}){}}}publicclassBlog{publicintId{get;set;}publicNameWrapperName{get;set;}}publicclassNameWrapper{publicstringName{get;set;}}
It currently isn't possible to specify a value-converted type as a parameter in raw SQL. It seems like the pre-convention configuration
DefaultTypeMapping
should make this work:... but I still get the exception:
Full repro
Raised by @juchom in npgsql/efcore.pg#2259
The text was updated successfully, but these errors were encountered: