public List <Orders> GetOrders() { var table = new OrdersDynamic(); return(table.Query(@"SELECT TOP 500 [WorkOrderID] AS Id, P.Name AS ProductName, [OrderQty] AS Quantity, [DueDate] AS Date FROM [AdventureWorks2014].[Production].[WorkOrder] AS WO INNER JOIN[Production].[Product] AS P ON P.ProductID = WO.ProductID").Select(x => new Orders { Id = x.Id, ProductName = x.ProductName, Quantity = x.Quantity, Date = x.Date }).ToList()); }
public Orders GetOrderById(int id) { var table = new OrdersDynamic(); var data = table.Query(@"SELECT [WorkOrderID] AS Id, P.Name AS ProductName, [OrderQty] AS Quantity, [DueDate] AS Date FROM [AdventureWorks2014].[Production].[WorkOrder] AS WO INNER JOIN[Production].[Product] AS P ON P.ProductID = WO.ProductID WHERE WorkOrderID = @0", id).FirstOrDefault(); return(new Orders { Id = data.Id, ProductName = data.ProductName, Quantity = data.Quantity, Date = data.Date }); }