Example #1
0
 public IList<Model.TextBlock> List(int pageindex, int pagesize, out int count)
 {
     Peanut.Expression exp = new Peanut.Expression();
     count = exp.Count<TextBlock>();
     int size = 20;
     return exp.List<TextBlock>(new Region(pageindex, size));
 }
Example #2
0
        public IList <Model.TextBlock> List(int pageindex, int pagesize, out int count)
        {
            Peanut.Expression exp = new Peanut.Expression();
            count = exp.Count <TextBlock>();
            int size = 20;

            return(exp.List <TextBlock>(new Region(pageindex, size)));
        }
Example #3
0
 public IList<Order> OnOrderSearch(ISession session, OrderSearch e)
 {
     Expression exp = new Expression();
     if (e.CustomerID != null)
         exp &= Models.Orders.customerID == e.CustomerID;
     if (e.EmployeeID > 0)
         exp &= Models.Orders.employeeID == e.EmployeeID;
     return exp.List<Models.Orders, Order>();
 }
Example #4
0
        public static Expression operator |(Expression exp1, Expression exp2)
        {
            if (exp1 == null || exp1.SqlText.Length == 0)
                return exp2;
            if (exp2 == null || exp2.SqlText.Length == 0)
                return exp1;
            Expression exp = new Expression();
           // exp.ParameterNameIndex = exp1.ParameterNameIndex > exp2.ParameterNameIndex ? exp1.ParameterNameIndex : exp2.ParameterNameIndex;
            exp.SqlText.Append("(");
            exp.SqlText.Append(exp1.ToString());
           
            exp.SqlText.Append(")");
            exp.Parameters.AddRange(exp1.Parameters);
            exp.SqlText.Append(" or (");
            exp.SqlText.Append(exp2.SqlText.ToString());
            exp.SqlText.Append(")");
            exp.Parameters.AddRange(exp2.Parameters);
            return exp;

        }
Example #5
0
        public IList<Blog> List(string category, int size, int index, out int pages)
        {
            Expression exp = new Expression();
            if (!string.IsNullOrEmpty(category))
                exp &= Blog.iD == BlogLinkCategory.blog[BlogLinkCategory.category == category];
            int count = exp.Count<Blog>();
            pages = count / size;
            if (count % size > 0)
                pages++;

            IList<Blog> result = exp.List<Blog>(new Region(index, size), Blog.createTime.Desc);
            foreach (Blog item in result)
            {
                item.Categories = ListCategories(item.ID);
            }
            return result;
        }
Example #6
0
 public IList<BlogCategory> ListCategories(string blog = null)
 {
     Expression exp = new Expression();
     if (blog != null)
         exp &= BlogCategory.iD == BlogLinkCategory.category[BlogLinkCategory.blog == blog];
     IList<BlogCategory> result = exp.List<BlogCategory>();
     foreach (BlogCategory item in result)
     {
         item.Blogs = (BlogLinkCategory.category == item.ID).Count<BlogLinkCategory>();
     }
     return result;
 }