public object Orders(EFCoreDB <NorthwindContext> db, int index, int product, int employee, string customer, string jwt_user, string jwt_role) { Console.WriteLine($"jwt_info:{jwt_user}/{jwt_role}"); SQL sql = @"select orders.*,(employees.FirstName || ' ' || employees.LastName) Employee, customers.CompanyName Customer from orders inner join employees on orders.EmployeeID = employees.EmployeeID inner join customers on orders.CustomerID = customers.CustomerID where 1=1"; if (employee > 0) { sql.And().Where <Employee>(e => e.EmployeeID == employee); } if (!string.IsNullOrEmpty(customer)) { sql.And().Where <Customer>(c => c.CustomerID == customer); } if (product > 0) { sql += " and orders.OrderID in(select orderid from 'Order Details' where ProductID=@p1)"; sql += ("@p1", product); } DBRegionData <ExpandoObject> result = new DBRegionData <ExpandoObject>(index, 10); result.Execute(db.DBContext, sql); foreach (dynamic item in result.Items) { sql = @"select [Order Details].*, Products.ProductName from [Order Details] inner join Products on [Order Details].ProductID= Products.ProductID Where [Order Details].OrderID=" + item.OrderID; item.Details = sql.List <ExpandoObject>(db.DBContext); } return(result); }
static async Task Main(string[] args) { SQL sql = @"select Orders.*,Employees.FirstName,Employees.LastName,Customers.CompanyName from Orders inner join Employees on Employees.EmployeeID=Orders.EmployeeID inner join Customers on Customers.CustomerID= Orders.CustomerID where 1=1"; int i = 3; int i1 = 4; sql.And().Where <Employee>(e => e.EmployeeID.In(i, i1)); DBRegionData <ExpandoObject> result = new DBRegionData <ExpandoObject>(0, 50); await result.ExecuteAsync <NorthwindContext>(sql); await Task.Delay(-1); }
public object Customers(EFCoreDB <NorthwindContext> db, string country, string name, int index) { SQL sql = "select * from customers where 1=1"; if (!string.IsNullOrEmpty(country)) { sql.And().Where <Customer>(c => c.Country == country); } if (!string.IsNullOrEmpty(name)) { sql.And().Where <Customer>(c => c.CompanyName.Contains(name)); } DBRegionData <ExpandoObject> result = new DBRegionData <ExpandoObject>(index, 20); result.Execute(db.DBContext, sql); return(result); }
public object Products(EFCoreDB <NorthwindContext> db, int index, string name, int category) { SQL sql = @"select products.*,categories.CategoryName from products inner join categories on products.CategoryID = categories.CategoryID where 1=1"; if (!string.IsNullOrEmpty(name)) { sql.And().Where <Product>(p => p.ProductName.StartsWith(name)); } if (category > 0) { sql.And().Where <Product>(p => p.CategoryID == category); } DBRegionData <ExpandoObject> result = new DBRegionData <ExpandoObject>(index, 20); result.Execute(db.DBContext, sql); return(result); }