Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }