articletagmappingcontroller.cs

来自「Maolz个人展示网站源码,全部的代码,.net」· CS 代码 · 共 97 行

CS
97
字号
using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace SubSonic.Generated
{
    /// <summary>
    /// Controller class for ArticleTagMappings
    /// </summary>
    public partial class ArticleTagMappingController
    {
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public ArticleCollection FetchRelveantArticlePagingByTagId(int tagId, int startRowIndex, int maximumRows)
        {
            ArticleTagMapping atm = new ArticleTagMapping(ArticleTagMapping.Columns.TagId, tagId);
            if (atm.IsNew)
            {
                return new ArticleCollection();
            }
            else 
            {
                
                int currentPageIndex=(int)(startRowIndex / maximumRows)+1;
                int pageSize = maximumRows;
                //Query qry = new Query(ArticleTagMapping.Schema)
                //    .WHERE(ArticleTagMapping.Columns.TagId, tagId)
                //    .SetSelectList(ArticleTagMapping.Columns.ArticleId)
                    //System.Data.IDataReader dr=new Select().From("Articles")
                //return DB.Select().From("Articles").Where("PKId").In(new Select("ArticleId").From("ArticleTagMappings").Where("TagId").IsEqualTo(tagId)).Paged(currentPageIndex, pageSize).ExecuteAsCollection<ArticleCollection>().OrderByDesc("PKId"); 
                //System.Data.IDataReader dr= DB.Select().From("Articles").Where("PKId").In(new Select("ArticleId").From(ArticleTagMapping.Schema).WhereExpression("tagid").IsEqualTo(tagId)).ExecuteReader();
                ////.ExecuteReader();
                //ArticleCollection ac = new ArticleCollection();
                //ac.LoadAndCloseReader(dr);
                //return ac;

                //System.Data.IDataReader dr = DB.Select().From("Articles").Where("PKId").In(new Select("ArticleId").From(ArticleTagMapping.Schema).WhereExpression("tagid").IsEqualTo(tagId)).ExecuteReader();
                //ArticleCollection ac = new ArticleCollection();
                //ac.LoadAndCloseReader(dr);
                //return ac;
                System.Data.IDataReader dr=SPs.GetPagingTagRelveantArticles(new int?(tagId), startRowIndex, maximumRows, false).GetReader();
                ArticleCollection ac = new ArticleCollection();
                ac.LoadAndCloseReader(dr);
                return ac;



            }
        }
        public ArticleCollection FetchRelveantArticleByTagId(int tagId)
        {
            if (tagId.Equals(-1))
            {
                return null;
            }
            else
            {
                System.Data.IDataReader dr = new Select().From("Articles")
                                                    .Where("PKId")
                                                    .In(
                                                        new Select("ArticleTagMappings")
                                                        .Where("TagId").IsEqualTo(tagId)
                                                        )
                                                    .OrderDesc("PKId")
                                                     .ExecuteReader();
                ArticleCollection ac = new ArticleCollection();
                ac.LoadAndCloseReader(dr);
                return ac;
            }
        }
        public int GetCount(int tagId) 
        {
            //return FetchRelveantArticleByTagId(tagId).Count;
            //if(tagId.Equals(-1))
            //    return 0;
            //else
            //    //SPs.RelveantArticle(new int?(tagId),
            //    return FetchRelveantArticleByTagId(tagId).Count;
            return Convert.ToInt32(SPs.GetPagingTagRelveantArticles(new int?(tagId), null, null, true).ExecuteScalar());

        }

        
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?