Skip to content

The InsertWithOutputIntoAsync method does not work correctly #3983

Description

@jangarach

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: has-prThere is active PR for issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions