Пример #1
0
        /// <summary>
        /// 返回符合查询条件的前 n 条结果
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public IList list(int count)
        {
            processQueryString();
            SqlBuilder builder = new SqlBuilder(_state.EntityInfo.Type);
            String     sql     = builder.GetFindConditionSql(_selectItems, _whereStr, _namedParameters, count);

            // cache
            IList list = ObjectPool.FindByQuery(_state.EntityInfo.Type, sql, _namedParameters);

            if (list != null)
            {
                return(list);
            }

            logger.Sql(LoggerUtil.SqlPrefix + "[FindBy]" + sql);

            ConditionInfo conditionInfo = new ConditionInfo();

            conditionInfo.Type         = _state.EntityInfo.Type;
            conditionInfo.State        = _state;
            conditionInfo.SelectedItem = _selectItems;
            conditionInfo.WhereString  = _whereStr;
            conditionInfo.Parameters   = _namedParameters;
            conditionInfo.Count        = count;
            conditionInfo.Sql          = sql;

            IList parentResults = FindByOperation.Find(conditionInfo);

            if (parentResults.Count > 0 && _state.EntityInfo.ChildEntityList.Count > 0 && _state.IsFindChild)
            {
                parentResults = findFromChild(parentResults);
            }

            // cache
            if ("*".Equals(_selectItems))
            {
                ObjectPool.AddQueryList(_state.EntityInfo.Type, sql, _namedParameters, parentResults);
            }

            return(parentResults);
        }
Пример #2
0
 public static Query Find(ObjectInfo obj, String condition)
 {
     return(FindByOperation.Find(condition, obj));
 }