using
System;
using
System.Linq;
using
System.Collections.Generic;
public
class
Student
{
public
int
id;
public
string
name;
public
int
dept_id;
public
int
add_id;
}
public
class
Department
{
public
int
dept_id;
public
string
dept_name;
}
public
class
Address
{
public
int
add_id;
public
string
address_name;
}
class
GFG{
static
void
Main(
string
[] args)
{
List<Student> students =
new
List<Student>()
{
new
Student{ id = 7058, name =
"sravan kumar"
,
dept_id = 1, add_id = 21 },
new
Student{ id = 7059, name =
"jyothika"
,
dept_id = 2, add_id = 22 },
new
Student{ id = 7072, name =
"harsha"
,
dept_id = 1, add_id = 22 },
new
Student{ id = 7076, name =
"khyathi"
,
dept_id = 4, add_id = 27 },
};
List<Department> departments =
new
List<Department>()
{
new
Department{ dept_id = 1, dept_name =
"CSE"
},
new
Department{ dept_id = 2, dept_name =
"CSE"
},
new
Department{ dept_id = 3, dept_name =
"IT "
},
};
List<Address> addresses =
new
List<Address>()
{
new
Address{ add_id = 21, address_name =
"hyd"
},
new
Address{ add_id = 22, address_name =
"railu-peta"
},
new
Address{ add_id = 24, address_name =
"chenchu-peta"
},
};
var
result = (
from
stu
in
students
join
dept
in
departments
on
stu
.dept_id
equals
dept
.dept_id
join
add
in
addresses
on
stu
.add_id
equals
add.add_id
select
new
{
ID = stu.id, Name = stu.name,
DeptName = dept.dept_name,
address = add.address_name
}).ToList();
foreach
(
var
e
in
result)
{
Console.WriteLine(
"\tID: "
+ e.ID +
"--> Name: "
+
e.Name +
"--> Department: "
+
e.DeptName +
"--> Address: "
+ e.address);
}
}
}