Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET entity
Hello!
I have code:
var listOfUsers = from a in context.CMSPI_CODICIACCESSO
                              join b in context.CMSPI_ANAGRAFICAINFOBASE
                              on a.IDANAGRAFICA equals b.IDANAGRAFICA
                              select b;
 

But this code returns only fields from table a. I need return all fields from every tables. How it make? Thank you
Posted 8-Apr-13 1:57am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this:
var listOfUsers = (from x in context.CMSPI_CODICIACCESSO
         join u in context.CMSPI_ANAGRAFICAINFOBASE on x.IDANAGRAFICA equals u.IDANAGRAFICA
    select new {
          RowA = x, RowB = u
    });
DataTable result = new DataTable();
foreach (var x in listOfUsers)
{
     result.Rows.Add(x.RowA , x.RowB);
}
 

 
--Amit
  Permalink  
v2
Comments
Junoli at 8-Apr-13 7:58am
   
So it is good solutions. But how i can display it at VIEW? at emp there is two objects:
RowA = {CMSPI.Models.CMSPI_CODICIACCESSO}
RowB = {CMSPI.Models.CMSPI_ANAGRAFICAINFOBASE}
and at each there are fields that i must show
_Amy at 8-Apr-13 8:05am
   
Marked as Answer and Again Undo. Why?
Anyways, see my updated solution with a Resultant DataTable. Now you can do anything with the result DataTable.
Junoli at 8-Apr-13 8:13am
   
i can not use DataTable. I must show it at table HTML.
_Amy at 8-Apr-13 8:15am
   
Yes, then loop through the DataTable and show the content in HTML Table. There should not be any problem in that.
Junoli at 8-Apr-13 8:31am
   
Can you show me example. I dont understand
_Amy at 8-Apr-13 8:36am
   
Try like this:

foreach(DataRow drow in result.Rows)
{
//Write your code here to put the values in Html Table. e.g.
//Console.WriteLine(drow["YourColumnName"].ToString());
}

 
--Amit
Junoli at 8-Apr-13 8:38am
   
I can repaet problem. At loop foreach @foreach (var emp in ViewBag.list)
i have at amp the next object: emp = { USERNAME = 1, COGNOME = ponm, NOME = olg, EMAIL = o@mail.su, CODICEFISCALE = 111 , PARTITAIVA = 222 , TELEFONOPRINCIPALE = 333333, TELEFONOSECONDARIO = 333, CELLULARE = 333, FAX = 33333, STATOANAGRAFICA = 3 }
 
How i can show TELEFONOPRINCIPALE, TELEFONOSECONDARIO and etc?
Junoli at 8-Apr-13 8:49am
   
If do how you advised me. then get error: Input array is longer than the number of columns in this table.
Junoli at 8-Apr-13 9:56am
   
Have idies?
Junoli at 9-Apr-13 3:35am
   
Problem is at dinamic object, need convert it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100