when inner join in linq how can i select same column without using model class

when inner join in linq how can i select same column without using model class



Actually ,I want to extract generic data from EF table without using models but unfortunately two columns with same name from different database crashed...


var query = (from jbct in entities.Table1.AsEnumerable()
join p in entities.Table2.AsEnumerable() on jbct.perid equals p.id
select new

jbct.id,
p.id
).ToList();






Frankly, I have no idea what you're asking.

– Gert Arnold
Sep 14 '18 at 7:13




2 Answers
2



try use a dynamic name


var query = (from jbct in entities.Table1.AsEnumerable()
join p in entities.Table2.AsEnumerable() on jbct.perid equals p.id
select new

Id1 = jbct.id,
Id2 = p.id

).ToList();






okay thanks. I'll also try this. I am able to return dynamic json results in my API without creating specific Models.I used genric collection class . IEnumerable<Dictionary<string, object>>.

– Zuly
Sep 14 '18 at 7:35







@Zuly you can create a dynamic object like this

– tdayi
Sep 14 '18 at 8:03



Now I've found now my solution to usie dictionary class


var query = (from jbct in entities.Table1.AsEnumerable() join p in entities.Table2.AsEnumerable() on jbct.perid equals p.id select new Dictionary<String, Object>

"jbct_id", jbct.id,
"p_id", p.id
).ToList();



Thanks






Still no idea what you're up to. I do know that because of the AsEnumerable() calls this is horribly inefficient code.

– Gert Arnold
Sep 14 '18 at 7:15


AsEnumerable()






Should I use " IQueryable<Dictionary<string, Object>>" .. instead of AsEnumerable()..

– Zuly
Sep 14 '18 at 7:36




Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)