public static void Excercise2() { // Objeto NO anonimo //var x = new ObjectClass{ Id = 2, Title = "jkhsfjs" }; //Objeto ANONIMO //var x = new { Id = 2, Title = "jkhsfjs" }; //SELECT Title, FirstName, LastName FROM Employees WHERE Title = 'Sales Representative'; var employeeQry = new EmployeesSC().GetEmployees().Select(s => new { s.Title, s.FirstName, s.LastName }).Where(w => w.Title == "Sales Representative").AsQueryable(); //Aqui materializamos el query var output = employeeQry.ToList(); //var od = new NORTHWNDContext().Products.Include(i => i.OrderDetails) // .Where(W => W.ProductId == 1) // .SelectMany(s => s.OrderDetails) // .Select(s => s.Order); //var o = od.ToList(); output.ForEach(fe => Console.WriteLine("Name: " + fe.FirstName + " Title: " + fe.Title)); }
private static void employeeSelect() { var employeeSelect = new EmployeesSC().GetEmployees().Select(s => new { //Proyección Lambda EmployeeId = s.EmployeeId, EmployeeFirstName = s.FirstName, EmployeeAdress = s.Address, EmployeeHomePhone = s.HomePhone, EmployeeNotes = s.Notes }).ToList(); }
public static void Excercise3() { //SELECT FirstName as Nombre, LastName as Apellido FROM Employees WHERE Title<> 'Sales Representative var employeeQry = new EmployeesSC().GetEmployees().Select(s => new { Nombre = s.FirstName, Apellido = s.LastName, s.Title, }).Where(w => w.Title != "Sales Representative"); var output = employeeQry.ToList(); }
public List <Employee> Get() { var employee = new EmployeesSC().GetEmployees().ToList(); return(employee); }
//SELECT * FROM Employees public static void Employee() { var EmployeeQry = new EmployeesSC().GetEmployees(); var output = EmployeeQry.ToList(); }
public static void Excercise1() { //SELECT *FROM Employees; var employeeQry = new EmployeesSC().GetEmployees(); var output = employeeQry.ToList(); }