Menu ▼

Previous Next

LINQ to SQL Cross Join :

Input tables
Department table
departments
Employees table
employees

LINQ Query :

MyDBDataContext sqlObj = new MyDBDataContext();

var employees = from emps in sqlObj.tblEmployees

                from depts in sqlObj.tblDepartments

                select new

                {

                    emps.EmployeeID,

                    emps.EmployeeName,

                    emps.Salary,

                    depts.DepartmentName

                };

gvemployees.DataSource = employees;

gvemployees.DataBind();


Output :
cross-join
Previous Next




Search dotnetlearners.com