question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The InsertWithOutputIntoAsync method does not work correctly

See original GitHub issue

Hi, I wanted to call the InsertWithOutputIntoAsync method with the following request:

 await source.InsertWithOutputIntoAsync(
    targetTable,
    valueFromTargetTable=> valueFromTargetTable,
    otherTable,
    valueFromTargetTable=> new OtherClass
            {
                Id = valueFromTargetTable.Id, 
                Status = 1
            });

But I caught an exception when calling such code:

System.InvalidCastException : Unable to cast object of type 'LinqToDB.Linq.Table`1[OtherTable]' to type 'System.Linq.IQueryable`1[TargetTable]'

When I started looking at the source code, what I saw was that the method has this code (IQueryable<TTarget>)outputTable link to the source: https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/LinqExtensions.Insert.cs/#L300

Why do you need a type conversion? The semantics of the method allows you to call the code that I have.

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MaceWinducommented, Feb 21, 2023
0reactions
jangarachcommented, Feb 22, 2023

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release Notes 3.0.0
With this release we fix escaping logic for database objects (e.g. table, schema, column, database, alias) and remove couple of quirks in ...
Read more >
linq2db.EntityFrameworkCore - bytemeta
linq2db.EntityFrameworkCore repo issues. ... UnwrapDataObjectInterceptor not beign called ... The InsertWithOutputIntoAsync method does not work correctly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found