Page 1 of 1

Typecast null to char and number in same column

Posted: Wed 19 Jun 2013 20:19
by Werlang
We have the following query:

Code: Select all

var list = _query.Search(x => x.DataSource.Equals(param1) && (x.User.Login.Equals(login) || x.User == null));

var result = 
    (from item in list
     select new
     {
         item,
         filters = item.Filters,
         data    = from a in item.Data
                   where a.User.Login == login
                   select new { data, data.Values },
         filters2 = from b in item.Filters2
                    select new { b, b.Values },
         default = item.Default,
         columns = from c in item.Columns
                   where c.Show
                   orderby c.Order
                   select c
     }).AsEnumerable();

result.First();
On SQL Server it runs OK, but on Oracle it produces a query which mixes char and number columns.

To simplify, it generates something like:

Code: Select all

select to_char(null) as a
from tab1
union select to_number(null) 
from tab2
As seen, there's a typecast to char and to number in the same column.

I'd like to know what can lead to such a SQL.

Thanks in advance. Please let me know if you need further information.

Re: Typecast null to char and number in same column

Posted: Fri 21 Jun 2013 16:18
by Shalex
Please specify the ORM framework you are using (e.g.: Entity Framework) and send us a small test project with the model.

Re: Typecast null to char and number in same column

Posted: Fri 21 Jun 2013 21:43
by Werlang
Hello

It'd take some time but we'll produce this sample.