Error when using multiple includes
Posted: Tue 26 Apr 2011 13:28
Hello,
I have an issue when using the Include statement.
When I try to include more then 2 relations there seems to be a problem:
These are fine:
But this one generates an error message {"ORA-01790: expression must have same datatype as corresponding expression"}:
After investigating the sql (ToTraceString of the ObjectQuery) that is generated I found the reason for the error:
The underlying query unions all tables, to have the same column format it will generate all columns for each table and set them to null if not applicable, for instance:
This way, oracle automatically gets the datatype from the column that is not null and unions without a problem for 2 tables.
I would expect the query form 3 tables to be the same:
But...for three tables the generated query is different:
This causes the datatype error, for some reason Oracle does not set the correct datatype for the column of table3.
I would like to know if there is another or better way to use multiple includes or if there is a workaround.
Maybe someone can help, because I am stuck.
Thanks,
Femke
I have an issue when using the Include statement.
When I try to include more then 2 relations there seems to be a problem:
These are fine:
Code: Select all
Context.Table.Include("Table1").Include("Table2").FirstOrDefault();
Context.Table.Include("Table1").Include("Table3").FirstOrDefault();
Context.Table.Include("Table2").Include("Table3").FirstOrDefault();
Code: Select all
Context.Table.Include("Table1").Include("Table2").Include("Table3").FirstOrDefault();
The underlying query unions all tables, to have the same column format it will generate all columns for each table and set them to null if not applicable, for instance:
Code: Select all
select field1, field2, null, null from table1
union all
select null, null, field1, null from table2
I would expect the query form 3 tables to be the same:
Code: Select all
select field1, field2, null, null from table1
union all
select null, null, field1, null from table2
union all
select null, null, null, field from table3
Code: Select all
select ... from (select field1, field2, null, null from table1
union all
select null, null, field1, null from table2)
union all
select null, null, null, field1 from table3
I would like to know if there is another or better way to use multiple includes or if there is a workaround.
Maybe someone can help, because I am stuck.
Thanks,
Femke