Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have 4 tables ,Which are as per below.
SQL
Table1

a1(primarykey)
a2
a3
................
Table2

b1 (primarykey)
a1(foreiegnkey)
b2
b3
.................
Table3

c1(primarykey)
b1(foreiegnkey)
c2
c3
...................
Table4

d1(primarykey)
c1(foreiegnkey)
d2
d3
.....................


var p = from r in db.Table1
        where r.a1 == Convert.ToInt32(Session["idforexcelpage"].ToString())
        join a in db.Table2 on r.Table1 equals a.Table2
        join b in db.Table3 on a.Table2 equals b.Table3
        join e in db.Table4 on b.Table3 equals e.Table4
        group a by new { a.b2,e.d3,b.c3,e.d2 } into g
        select new
               {

                            InviteeName =g.Key.b2
                            Text = g.Key.d3,
                            Answer = g.Key.c3,
                            Email = g.Key.d2

                };




Here is my Query and table information.

But use with this query i not give my Excepted Output,Here I want group from column b2 which is field of Table2.

But i don't grouping it.Can anuone Help me to solve this Isssue..?

Thanks in advance.
Posted
Updated 16-Apr-14 21:37pm
v2

1 solution

if you want to group by column b2 only, then

C#
var p = from r in db.Table1
        where r.a1 == Convert.ToInt32(Session["idforexcelpage"].ToString())
        join a in db.Table2 on r.Table1 equals a.Table2
        join b in db.Table3 on a.Table2 equals b.Table3
        join e in db.Table4 on b.Table3 equals e.Table4
        group a by new a.b2 into g
        select new
               {InviteeName =g.Key};
 
Share this answer
 
Comments
ketan italiya 17-Apr-14 5:26am    
Thanks for the solution.

But i use repeater and i also want to bind other column in it.like,
InviteeName,Text,Answer ,Email then what should i do.
my problem is that with that.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900