示例#1
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public static IPageOfList <AttachmentInfo> List(AttachmentSearchSetting setting)
        {
            FastPaging fp = new FastPaging();

            fp.PageIndex   = setting.PageIndex;
            fp.PageSize    = setting.PageSize;
            fp.Ascending   = false;
            fp.TableName   = "Attachment";
            fp.TableReName = "p";
            fp.PrimaryKey  = "ID";
            fp.QueryFields = "p.*";
            fp.OverOrderBy = " Sort ASC,CreateDateTime DESC";
            fp.WithOptions = " WITH(NOLOCK)";

            StringBuilder sbCondition = new StringBuilder();

            sbCondition.Append("    IsDeleted = 0 ");
            if (setting.CategoryId > 0)
            {
                sbCondition.Append(@"   AND EXISTS(
		                            SELECT * FROM Categories AS AC WITH(NOLOCK) 
		                            WHERE (AC.ID = @CID OR CHARINDEX(','+CAST(@CID AS NVARCHAR(MAX))+',',','+AC.ParentIdList+',') >0)
		                            AND p.CategoryId = AC.ID
                                )");
            }
            fp.Condition = sbCondition.ToString();

            SqlParameter[] param =
            {
                new SqlParameter("CID", SqlDbType.Int),
            };
            param[0].Value = setting.CategoryId;

            IList <AttachmentInfo> list = new List <AttachmentInfo>();
            DataTable dt = Goodspeed.Library.Data.SQLPlus.ExecuteDataTable(CommandType.Text, fp.Build2005(), param);

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(Get(dr));
                }
            }

            int count = Convert.ToInt32(Goodspeed.Library.Data.SQLPlus.ExecuteScalar(CommandType.Text, fp.BuildCountSQL(), param));;

            return(new PageOfList <AttachmentInfo>(list, setting.PageIndex, setting.PageSize, count));
        }
示例#2
0
 /// <summary>
 /// 列表
 /// </summary>
 /// <param name="setting"></param>
 /// <returns></returns>
 public static IPageOfList <AttachmentInfo> List(AttachmentSearchSetting setting)
 {
     return(AttachmentManage.List(setting));
 }
示例#3
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public static IPageOfList<AttachmentInfo> List(AttachmentSearchSetting setting)
        {
            FastPaging fp = new FastPaging();
            fp.PageIndex = setting.PageIndex;
            fp.PageSize = setting.PageSize;
            fp.Ascending = false;
            fp.TableName = "Attachment";
            fp.TableReName = "p";
            fp.PrimaryKey = "ID";
            fp.QueryFields = "p.*";
            fp.OverOrderBy = " Sort ASC,CreateDateTime DESC";
            fp.WithOptions = " WITH(NOLOCK)";

            StringBuilder sbCondition = new StringBuilder();
            sbCondition.Append("    IsDeleted = 0 ");
            if (setting.CategoryId > 0)
            {
                sbCondition.Append(@"   AND EXISTS(
		                            SELECT * FROM Categories AS AC WITH(NOLOCK) 
		                            WHERE (AC.ID = @CID OR CHARINDEX(','+CAST(@CID AS NVARCHAR(MAX))+',',','+AC.ParentIdList+',') >0)
		                            AND p.CategoryId = AC.ID
                                )");
            }
            fp.Condition = sbCondition.ToString();

            SqlParameter[] param = { 
                                    new SqlParameter("CID",SqlDbType.Int),
                                   };
            param[0].Value = setting.CategoryId;

            IList<AttachmentInfo> list = new List<AttachmentInfo>();
            DataTable dt = Goodspeed.Library.Data.SQLPlus.ExecuteDataTable(CommandType.Text, fp.Build2005(),param);
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(Get(dr));
                }
            }

            int count = Convert.ToInt32(Goodspeed.Library.Data.SQLPlus.ExecuteScalar(CommandType.Text, fp.BuildCountSQL(),param)); ;
            return new PageOfList<AttachmentInfo>(list, setting.PageIndex, setting.PageSize, count);
        }
示例#4
0
 /// <summary>
 /// 列表
 /// </summary>
 /// <param name="setting"></param>
 /// <returns></returns>
 public static IPageOfList<AttachmentInfo> List(AttachmentSearchSetting setting)
 {
     return AttachmentManage.List(setting);
 }