//
 public DataTable GetListSQL(Criteria criteria, Order order)
 {
     DataTable result;
     using (ISession session = sessionFaction.OpenSession())
     {
         string sql = "SELECT * FROM vipsoft_category";
         result = session.ExecuteDataTable(sql, CommandType.Text);
     }
     return result;
 }
Example #2
0
 //自定义SQL
 public List<Category> GetListSQL(Criteria criteria,Order order)
 {
     List<Category> result;
     using (ISession session = sessionFaction.OpenSession())
     {
     //                string sql = "SELECT * FROM vipsoft_category WHERE depth=?P_depth";
     //                DbParameter[] s = session.GetParameters<Category>("depth");
     //                s[0].Value = 1;
         result = session.Load<Category>(criteria,order);
     }
     return result;
 }
Example #3
0
 public static CmdParameter CreateDataCountSql(ISessionImplementor session, IEntityPersister entityPersister, Criteria criteria)
 {
     var classMetadata = entityPersister.ClassMetadata;
     var result = new CmdParameter();
     var parameters = new List<DbParameter>();
     var sql = new StringBuilder();
     sql.AppendFormat("SELECT COUNT(1) FROM {0} ", classMetadata.TableName);
     if (criteria != null && criteria.CriterionList != null && criteria.CriterionList.Count > 0)
     {
         criteria.Driver = entityPersister.Driver;
         criteria.DicParameter = entityPersister.GetParameter(session);
         criteria.DbParameter = parameters;
         sql.Append(" WHERE ").Append(criteria.ToString(classMetadata));
         result.Parameters = parameters.ToArray();
     }
     sql.Append(entityPersister.Driver.MultipleQueriesSeparator);
     result.CommandText = sql.ToString();
     log.Info(sql);
     return result;
 }
Example #4
0
        public static CmdParameter CreateSelectSql2(ISessionImplementor session, IEntityPersister entityPersister, Criteria criteria, Order order)
        {
            var classMetadata = entityPersister.ClassMetadata;
            var result = new CmdParameter();

            //if (string.IsNullOrEmpty(obj.Conditaion))
            //{
            //    var columnInfo = classMetadata.ColumnInfos.Find(t => t.IsPrimaryKey);
            //    if (columnInfo != null)
            //    {
            //        var v = columnInfo.PropertyInfo.FastGetValue(obj);
            //        if (!IsNull(v)) result = CreateSelectSql(session, entityPersister, v);
            //    }

            //}
            var parameters = new List<DbParameter>();
            //entityPersister.Driver.FormatNameForSql(columnInfo.Name)

            // string rConditaion = GetConditaion(session, entityPersister, obj, out parameters);

            var sql = new StringBuilder("SELECT ");
            //sql.Append(string.IsNullOrEmpty(obj.ResultColumns) ? "*" : obj.ResultColumns);
            sql.Append("*");
            sql.AppendFormat(" FROM {0} ", classMetadata.TableName);
            if (criteria != null && criteria.CriterionList != null && criteria.CriterionList.Count > 0)
            {
                criteria.Driver = entityPersister.Driver;
                criteria.DicParameter = entityPersister.GetParameter(session);
                criteria.DbParameter = parameters;
                sql.Append(" WHERE ").Append(criteria.ToString(classMetadata));
                result.Parameters = parameters.ToArray();
            }
            // entityPersister.SetDbParamter(session, parameters, columnInfo.Name, value);
            //var where = GetWhereCaluse(rConditaion);
            //if (where.Length > 0)
            //{
            //    sql.AppendFormat(" WHERE {0} ", where);
            //    result.Parameters = parameters.ToArray();
            //}
            //sql.Append(obj.OrderBy ?? "" );
            sql.Append(order != null ? order.ToString(classMetadata) : "");
            sql.Append(entityPersister.Driver.MultipleQueriesSeparator);
            result.CommandText = sql.ToString();
            log.Info(sql);
            return result;
        }
Example #5
0
 public Criterion(LOP logicOperation, Criteria criteria)
 {
     LogicOperation = logicOperation;
     Value = criteria;
 }
Example #6
0
 public Criterion(Criteria criteria)
 {
     LogicOperation = LOP.AND;
     Value = criteria;
 }
Example #7
0
 public Criteria Add(LOP logicOperation, Criteria criteria)
 {
     this.AddCriterion(new Criterion(logicOperation, criteria));
     return(this);
 }
Example #8
0
 public Criteria Add(Criteria criteria)
 {
     this.AddCriterion(new Criterion(criteria));
     return(this);
 }
Example #9
0
 /// <summary>
 /// 如果有子分类就显示子分类,如果没有就显示同级分类
 /// </summary>
 /// <returns></returns>
 public ActionResult NavigationMenu()
 {
     ViewBag.CurrentCategory = CurrentCategory;
     // var model = new Category { ID = CId, Conditaion = "parent_id=[ID]" };
     var criteria = new Criteria("ParentID", CId);
     criteria.Add(LOP.AND, "Status", 1);
     var list = CategoryService.GetList(criteria, new Order("sequence"));
     if (list.Count == 0)  //有子类就显示子类,没有子类就显示同级节点。
     {
         list = CategoryService.GetBrotherNode(CId);
     }
     return View(list);
 }
Example #10
0
 public Criteria Add(LOP logicOperation, Criteria criteria)
 {
     this.AddCriterion(new Criterion(logicOperation, criteria));
     return this;
 }
Example #11
0
 public Criteria Add(Criteria criteria)
 {
     this.AddCriterion(new Criterion(criteria));
     return this;
 }