New Posts New Posts RSS Feed: Display data from two table
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Display data from two table

 Post Reply Post Reply
Author
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Topic: Display data from two table
    Posted: 26-Aug-2010 at 9:55am
Hi
I can displya record from single table with this code

 var query = _mgr.STUDENTs;
query.ExecuteAsync(op => op.Results.ForEach(Students.Add));
   StudentGrid.ItemsSource = Students;

but I like to make join with another table and wanted to show data in single grid

for that i write this linq
var query2 = from STUDENT in Students
                             join SORDER in Sorders
                             on STUDENT.ID equals SORDER.SORDER_ID
                             select new
                             {
                                 STUDENT.ID,
                                 STUDENT.NAME,
                                 STUDENT.ADDRESS,
                                 SORDER.SORDER_ID,
                                 SORDER.OCITY
                             };
               
problem is I am not able to bind this query with datagrid

any help?
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 26-Aug-2010 at 5:01pm
Bala;

Try assigning the grid's ItemsSource to query2.ToList();
Back to Top
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Posted: 27-Aug-2010 at 4:46am
I try to assing but giving error

There is no ExecuteAsync() for query2

query.Ex....



Do you know How can I assing with this query. I made query with lambda but they also have error
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 27-Aug-2010 at 10:35am
I would rewrite your query like this

var query2 = from STUDENT in EntityManager.Students
                             join SORDER in 
EntityManager.Sorders
                             on STUDENT.ID equals SORDER.SORDER_ID
                             select new
                             {
                                 STUDENT.ID,
                                 STUDENT.NAME,
                                 STUDENT.ADDRESS,
                                 SORDER.SORDER_ID,
                                 SORDER.OCITY
                             };

then assign it like this

DataGrid.ItemsSource = query2.ToList();

Please try that and let me know.
Back to Top
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Posted: 27-Aug-2010 at 10:43am
Hi

This is still giving error
EntityManager.Students

Error:Does not contrain the defination of Students and no extension method studen accepting first
arugment type 'Students.Model.StudentEntities

Still i am stucking on this..


Thanks
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 27-Aug-2010 at 10:49am
The EntityManager that you put is your EntityManager assigned to your model. Please see my code sample below working with the NorthwindIB database that comes when you install your DevForce.

var _mgr = new NorthwindIBEntityManager();

var query2 = from employee in _mgr.Employees
                   join order in _mgr.Orders
                   on employee.EmployeeID equals order.EmployeeID
                   where employee.EmployeeID == 5
                   select new {
                     employee.EmployeeID,
                     employee.FirstName,
                     employee.LastName,
                     order.OrderID,
                     order.ShipCity
                   };

dataGrid.ItemsSource = query2.ToList();
Back to Top
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Posted: 27-Aug-2010 at 12:27pm
Hi

Thanks very much

its working just need more figureout due to list.. but finally acheived result..

Thanks a Million..
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 27-Aug-2010 at 1:46pm
Sounds good. Glad I could help.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down