I have got a native join sub query problem in MySQL Entity. SQL code is;
DB structure is;
tbl_urunler_kod
id, kod
– 1, pkod1
– 2, pkod2
– 3, pkod3
tbl_urunler
id, kod_id
– 1, 1
– 2, 2
– 3, 3
– 4, null
– 5, null
– 6, null
– 7, null
– 8, null
– 9, null
SELECT (SELECT k.kod FROM tbl_urunler_kod k WHERE k.id=t.kod_id) AS kod FROM tbl_urunler t
its giving 9 records.
I try this,
var SQL = (from p in SME.tbl_urunler
from k in SME.tbl_urunler_kod
where k.id == p.kod_id
select new
{
kod = k.kod
});
its returning only 3 records. Because tbl_urunler_kod have got only not null 3 records. Other 6 records is null. I wanna see all records. How can i do this.
And i try this;
var SQL2 = (from p in SME.tbl_urunler
select new
{
kod = (from k in SME.tbl_urunler_kod where k.id == p.kod_id select new { k.kod })
});
Its giving this error;
'System.Data.Common.Internal.Materialization.CompensatingCollection`1[f__AnonymousType0`1[System.String]]' türündeki nesne 'System.String' türüne atılamadı. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: 'System.Data.Common.Internal.Materialization.CompensatingCollection`1[f__AnonymousType0`1[System.String]]' türündeki nesne 'System.String' türüne atılamadı.
Thanks for your help.
I was created a little simulatin for this.
Please look the results;
Result 1
Result 2
Result 3
Result 4
Result 5
Result 6
Result 7
Thanks.