-1

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

Here is the query

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();
ZarNi Myo Sett Win
  • 1,353
  • 5
  • 15
  • 37
Zuly
  • 37
  • 7

2 Answers2

1

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();
tdayi
  • 142
  • 5
  • 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>. – Zuly Sep 14 '18 at 07:35
  • @Zuly you can create a dynamic object like this – tdayi Sep 14 '18 at 08:03
0

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

Dictionary with object as value

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

Zuly
  • 37
  • 7