Error : The expression of type '...' is not a sequence.

I use Linqpad extensively for querying databases. Today I got the following error when doing a Union operation between two result sets.
The expression of type 'System.Linq.IQueryable1[<>f__AnonymousType43[System.Int64,System.String]]' is not a sequence
Following is the sequence of steps I did.

I am using a Oracle database and added a connection in LinqPad using IQToolkit. I have 2 Tables with almost similar structure.

Field1 int
Field2 long
Field3 string

Field2 long
Field3 string
The table2 is similar in structure to Table1 except for the 'Field1' field. I want to join the data in two tables.

var firstTableData = (from data in Table1
select new{Field2 = data.Feild2, Field3 = data.Field3});

var secondTableData = (from data in Table2
select new{Field2 = data.Field2,Field3 = data.Field3});

var combined = firstTableData.Union(secondTableData);

At this point, Dump displays the combined Data from both tables.

Now when I use this combined data in a join with another query like

var newData = (from t3 in Table3
join c1 in combined on t3.Field2 equals c1.Field2
select {...});

In the above query, I am getting the issue

The expression of type 'System.Linq.IQueryable`1[<>f__AnonymousType4`3[System.Int64,System.String]]' is not a sequence

The structure of Table3 is as follows.

Field1 long
Field2 long

The Field2 in Table3 can contain values from Field2 of Table1 or Field2 of Table2. That is why i am combining the Field2 values from Table1 and Table2.

I have tried calling combined.AsQueryable(), combined.AsEnumerable() and also tried 'Concat' instead of 'Union' for combined.

var combined = firstTableData.Concat(secondTableData);
Nothing seemed to work.

Am I missing anything. It keeps me wondering that Dump() method does not have any such complaints. Please let me know if you need more information on this.

Can anybody suggest corrections to the linq queries(if they are not correct).


Can anybody suggest corrections to the linq queries i am using if they are not correct.


  • It sounds like it could be a limitation in the IQ driver.
  • Thanks Joe for your reply.
    Can you suggest any work around to achieve the expected results i am looking for.
    If it turns out to be issue/limitation with IQ Driver, can IQ Driver be updated to fix this issue.
  • Hey Joe,
    can you suggest some work around for that.
  • Hmm.
    There is no update on this issue since sometime.

    Can somebody let me know a workaround for this?
  • Unfortunately I have run into the same issue with SQLite trying to use the IQ driver or the LINQ to DB driver. It seems like neither implements Union or Concat.
  • If the problem is that the IQ driver can't handle Concat or Union, you could work around this by calling .AsEnumerable() or .ToArray() to make concatenation happen on the client-side instead:
    var data1 = <some query>.ToArray();
    var data2 = <some query>.ToArray();
    var query = data1.Unoin (data2);
    This won't cause a significant performance impact, because the data1 and data2 queries will still occur on the server.
  • I don't that is true if your union has some other conditions - consider data1.Union(data2).Take(5) or data1.Concat(data2).Where(r => smallList.Contains(r.Id))

    Also, even in union that may not be true since there is an implicit distinct. Definitely true for concat, however.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!