Ejemplo n.º 1
0
            public void DataSetLinq116()
            {
                EmployeeDataSet.EmployeesTableDataTable employees = new EmployeeDataSet.EmployeesTableDataTable();
                employees.AddEmployeesTableRow(5, "Jeff Jones", 60000);
                employees.AddEmployeesTableRow(6, "Geoff Webber", 85000);
                employees.AddEmployeesTableRow(7, "Alan Fox", 85000);
                employees.AddEmployeesTableRow(8, "Dwight Schute", 101000);
                employees.AddEmployeesTableRow(9, "Chaz Hoover", 99999);

                var q = employees.Select(emp => new { EmployeeID = emp.ID, EmployeeName = emp.Name, Employee = emp }).OrderBy(e => e.EmployeeName);

                foreach (var o in q)
                {
                    Console.WriteLine("Id = {0}, Name = {1}", o.EmployeeID, o.EmployeeName);
                }
            }
Ejemplo n.º 2
0
            public void DataSetLinq115()
            {
                EmployeeDataSet.EmployeesTableDataTable employees = new EmployeeDataSet.EmployeesTableDataTable();
                employees.AddEmployeesTableRow(5, "Jeff Jones", 60000);
                employees.AddEmployeesTableRow(6, "Geoff Webber", 85000);
                employees.AddEmployeesTableRow(7, "Alan Fox", 85000);
                employees.AddEmployeesTableRow(8, "Dwight Schute", 101000);
                employees.AddEmployeesTableRow(9, "Chaz Hoover", 99999);

                var q = employees.Where(e => e.Salary >= 85000).OrderBy(e => e.Name);

                foreach (var emp in q)
                {
                    Console.WriteLine("Id = {0}, Name = {1}", emp.ID, emp.Name);
                }
            }
Ejemplo n.º 3
0
            public void DataSetLinq117()
            {
                EmployeeDataSet.EmployeesTableDataTable employees = new EmployeeDataSet.EmployeesTableDataTable();
                employees.AddEmployeesTableRow(5, "Jeff Jones", 60000);
                employees.AddEmployeesTableRow(6, "Geoff Webber", 85000);
                employees.AddEmployeesTableRow(7, "Alan Fox", 85000);
                employees.AddEmployeesTableRow(8, "Dwight Schute", 101000);
                employees.AddEmployeesTableRow(9, "Chaz Hoover", 99999);

                EmployeeDataSet.EmployeesTableDataTable filteredEmployees = new EmployeeDataSet.EmployeesTableDataTable();

                var q = from e in employees
                        where e.ID > 7
                        select e;

                q.CopyToDataTable(filteredEmployees, LoadOption.OverwriteChanges);

                PrettyPrintDataTable(filteredEmployees);
            }