Webapplication
department_table
employee
In Employee table, Did field is foreign key of Department_table.
Employee
Did
Department_table
[OperationContract] List<Class1> getdata();
DatabaseEntities obj = new DatabaseEntities(); public List<Class1> getdata() { var x = from b in obj.Employees join a in obj.Department_table on b.Did equals a.Did select new Class1 { Name = b.Name, Address = b.Address, Department = a.Department }; return x.ToList(); }
ServiceReference
ServiceReference1.ServiceClient obj = new ServiceReference1.ServiceClient(); public ActionResult Index() { var x=obj.getdata(); var y = x.ToList(); var data = new List<Class1>(); foreach(var item in y) { data.Add(new Class1 { Name = item.Name, Address=item.Address, Department=item.Department }); } return View(data); }
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)