当前位置: 首页>>代码示例>>C#>>正文


C# SortDirection.ToString方法代码示例

本文整理汇总了C#中SortDirection.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SortDirection.ToString方法的具体用法?C# SortDirection.ToString怎么用?C# SortDirection.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortDirection的用法示例。


在下文中一共展示了SortDirection.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SortExpressionLink

        public static MvcHtmlString SortExpressionLink(
            this HtmlHelper helper,
            string title,
            string sortExpression,
            SortDirection direction = SortDirection.Ascending,
            object htmlAttributes = null)
        {
            var a = new TagBuilder("a");

            if (htmlAttributes != null)
            {
                // get the attributes
                IDictionary<string, object> attributes =
                    HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)
                        as IDictionary<string, object>;

                // set the attributes
                a.MergeAttributes(attributes);
            }

            var i = new TagBuilder("i");
            i.MergeAttribute("class", "indicator");

            a.AddCssClass("sort-expression-link");

            a.MergeAttribute("title", title);
            a.MergeAttribute("href", "#" + sortExpression);
            a.MergeAttribute("data-sort-expression", sortExpression);
            a.MergeAttribute("data-sort-direction", direction.ToString());
            a.InnerHtml = title + i.ToString(TagRenderMode.Normal);

            return
                MvcHtmlString.Create(a.ToString(TagRenderMode.Normal));
        }
开发者ID:Neilski,项目名称:URF-Identity,代码行数:34,代码来源:SortExpressionLink.cs

示例2: GetCommentXml

        public static XDoc GetCommentXml(IList<CommentBE> comments, bool collection, string suffix, bool? includeParentInfo, uint? offset, SortDirection? sortDir, XDoc doc, XUri commentCollectionUri, uint? totalCount) {

            bool requiresEnd = false;
            if(collection) {
                string rootCommentsNode = string.IsNullOrEmpty(suffix) ? "comments" : "comments." + suffix;
                if(doc == null) {
                    doc = new XDoc(rootCommentsNode);
                } else {
                    doc.Start(rootCommentsNode);
                    requiresEnd = true;
                }

                if((offset ?? 0) > 0) {
                    doc.Attr("offset", offset.Value);
                }

                if((sortDir ?? SortDirection.UNDEFINED) != SortDirection.UNDEFINED) {
                    doc.Attr("sort", sortDir.ToString().ToLowerInvariant());
                }
                doc.Attr("count", comments.Count);
                if(totalCount != null) {
                    doc.Attr("totalcount", totalCount.Value);
                }
            } else {
                doc = XDoc.Empty;
            }

            if(commentCollectionUri != null) {
                doc.Attr("href", commentCollectionUri);
            }

            foreach(CommentBE c in comments) {
                doc = AppendCommentXml(doc, c, suffix, includeParentInfo);
            }

            if(requiresEnd) {
                doc.End();
            }

            return doc;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:41,代码来源:CommentBL.cs

示例3: GetPagedList

        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<CarApplyInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< CarApplyInfo> list = new List< CarApplyInfo>();

            Query q = CarApply .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            CarApplyCollection  collection=new  CarApplyCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (CarApply  carApply  in collection)
            {
                CarApplyInfo carApplyInfo = new CarApplyInfo();
                LoadFromDAL(carApplyInfo,   carApply);
                list.Add(carApplyInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
开发者ID:xingfudaiyan,项目名称:OA,代码行数:32,代码来源:CarApplyInfo.cs

示例4: GetPagedList

        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<FilePermissionInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< FilePermissionInfo> list = new List< FilePermissionInfo>();

            Query q = FilePermission .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            FilePermissionCollection  collection=new  FilePermissionCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (FilePermission  filePermission  in collection)
            {
                FilePermissionInfo filePermissionInfo = new FilePermissionInfo();
                LoadFromDAL(filePermissionInfo,   filePermission);
                list.Add(filePermissionInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
开发者ID:xingfudaiyan,项目名称:OA,代码行数:32,代码来源:FilePermissionInfo.cs

示例5: GetPagedList

        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<ActionMasterInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< ActionMasterInfo> list = new List< ActionMasterInfo>();

            Query q = ActionMaster .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            ActionMasterCollection  collection=new  ActionMasterCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (ActionMaster  actionMaster  in collection)
            {
                ActionMasterInfo actionMasterInfo = new ActionMasterInfo();
                LoadFromDAL(actionMasterInfo,   actionMaster);
                list.Add(actionMasterInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
开发者ID:xingfudaiyan,项目名称:OA,代码行数:32,代码来源:ActionMasterInfo.cs

示例6: GetUserReputationList

        /// <summary>
        /// Generates user reputation object
        /// </summary>
        /// <param name="creator"></param>
        /// <param name="modClass"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static UserReputationList GetUserReputationList(IDnaDataReaderCreator creator, int modClassId, int modStatus,
            int days, int startIndex, int itemsPerPage, SortBy sortBy, SortDirection sortDirection)
        {
            UserReputationList userRepList = new UserReputationList()
            {
                days = days,
                modClassId = modClassId,
                modStatus = modStatus,
                startIndex = startIndex,
                itemsPerPage = itemsPerPage,
                sortBy = sortBy,
                sortDirection = sortDirection
            };

            using (IDnaDataReader dataReader = creator.CreateDnaDataReader("getuserreputationlist"))
            {
                dataReader.AddParameter("modClassId", modClassId);
                dataReader.AddParameter("modStatus", modStatus);
                dataReader.AddParameter("startIndex", startIndex);
                dataReader.AddParameter("itemsPerPage", itemsPerPage);
                dataReader.AddParameter("days", days);
                dataReader.AddParameter("sortby", sortBy.ToString());
                dataReader.AddParameter("sortdirection", sortDirection.ToString());
                
                dataReader.Execute();

                while(dataReader.Read())
                {
                    var userRep = new UserReputation();
                    userRep.UserId = dataReader.GetInt32NullAsZero("userid");
                    userRep.ModClass = ModerationClassListCache.GetObject().ModClassList.FirstOrDefault(x => x.ClassId == dataReader.GetInt32NullAsZero("modclassid"));
                    userRep.CurrentStatus = (ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("currentstatus");
                    userRep.ReputationDeterminedStatus = (ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("ReputationDeterminedStatus");
                    userRep.ReputationScore = dataReader.GetInt16("accumulativescore");
                    userRep.LastUpdated = new DateElement(dataReader.GetDateTime("lastupdated"));
                    userRep.UserName = dataReader.GetStringNullAsEmpty("UserName");
                    
                    userRepList.Users.Add(userRep);
                    userRepList.totalItems = dataReader.GetInt32NullAsZero("total");
                }
            }
            return userRepList;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:50,代码来源:UserReputationList.cs

示例7: Group

 public virtual void Group(string field, SortDirection direction)
 {
     this.Call("group", field, direction.ToString().ToLowerInvariant());
 }
开发者ID:hh22333,项目名称:Ext.NET.Community,代码行数:4,代码来源:StoreBase.cs

示例8: CreateSortArrows

        ///<summary>
        ///Takes a GridView object and attaches a suitable sort artist to the headerrow cells of any sortable columns
        ///</summary>
        ///<param name="gridView">The <see cref="System.Web.UI.WebControls.GridView" /> object whose headerrow cells are to be managed</param>
        ///<param name="defaultSortExpression">The default sort expression of the GridView data as <see cref="System.String" /></param>
        ///<param name="defaultSortDirection">The default sort direction of the GridView data as <see cref="System.Web.UI.WebControls.SortDirection" /></param>
        ///<param name="sortImagesFolder">The folder where the sort images are stored as <see cref="System.String" />. The sort images must be named sort_ascending.gif, sort_descending.gif and sort_unsorted.gif.</param>
        ///<param name="viewState">The page ViewState object that will allow tracking of the current sortorder. Only used when the sort has been performed using <see cref="William.Model.Entity.EntitySorter(Of T)" /></param>
        ///<param name="throwEmtpyDataException">If true an error is thrown if the gridview contains no data</param>
        ///<remarks>Must be run from within the PreRender event of the GridView so that the HeaderRow cells are created</remarks>
        public static void CreateSortArrows(System.Web.UI.WebControls.GridView gridView, string defaultSortExpression, SortDirection defaultSortDirection, string sortImagesFolder, StateBag viewState, bool throwEmtpyDataException)
        {

            // Check to see if the GridView contains rows of data. If there is no data throw an exception or exit the subroutine
            if (gridView.Rows.Count == 0)
                if (throwEmtpyDataException)
                    throw new Exception(string.Format("The GridView \"{0}\" has no data.{1}Please ensure that you check the GridView has rows of data before running the CreateSortArrows shared method.", gridView.ID, Environment.NewLine));
                else
                    return;
            
            // Check to see that the GridView has been created before working with the HeaderRow cells
            // Although the RowCreated event fires after every row is created the actual GridView is
            // not created until after all rows have been created
            if (gridView.HeaderRow == null)
                throw new Exception(string.Format("The GridView \"{0}\" has not yet been created.{1}Please check that you are running the CreateSortArrows shared method from within the GridView's PreRender event handler.", gridView.ID, Environment.NewLine));
            
            // Enumerate the columns and create the arrows for each sortable column
            foreach(DataControlField dcf in gridView.Columns)
            {
                if (!string.IsNullOrEmpty(dcf.SortExpression))
                {

                    string sortDirection = string.Empty;

                    // Work out which arrow is to be used for this column. If viewstate is passed in
                    // use William.Model.Data.EntitySorter's custom tracking, otherwise use the properties of the gridview
                    if (viewState != null)
                    {

                        if (dcf.SortExpression == (string)viewState["EntitySortProperty"])
                            sortDirection = ((SortDirection)viewState["EntitySortDirection"]).ToString();
                        else if (string.IsNullOrEmpty((string)viewState["EntitySortProperty"]) && dcf.SortExpression == defaultSortExpression)
                        {
                            sortDirection = defaultSortDirection.ToString();
                            viewState["EntitySortProperty"] = defaultSortExpression;
                            viewState["EntitySortDirection"] = defaultSortDirection;
                        }
                        else
                            sortDirection = "Unsorted";

                    } 
                    else
                    {

                        if (dcf.SortExpression == gridView.SortExpression)
                            sortDirection = gridView.SortDirection.ToString();
                        else if (string.IsNullOrEmpty(gridView.SortExpression) && dcf.SortExpression == defaultSortExpression)
                            sortDirection = defaultSortDirection.ToString();
                        else
                            sortDirection = "Unsorted";

                    }

                    Image sortImage = new Image();
                    sortImage.ImageUrl = string.Format(sortImagesFolder + "sort_{0}.gif", sortDirection.ToLower());
                    sortImage.AlternateText = string.Format("Sort Order: {0}", sortDirection);
                    sortImage.ToolTip = string.Format("Sort Order: {0}", sortDirection);
                    sortImage.Style.Add("margin-left", "5px");

                    gridView.HeaderRow.Cells[gridView.Columns.IndexOf(dcf)].Controls.Add(sortImage);

                }
            }

        } // CreateSortArrows
开发者ID:wduffy,项目名称:Toltech.Mvc,代码行数:75,代码来源:GridViewTools.cs

示例9: GetIncidents

        /// <summary>
        ///  Used to query current and historical PagerDuty incidents over a date range
        /// </summary>
        /// <param name="since">Start date</param>
        /// <param name="until">End date</param>
        /// <param name="fields">Specify which fields return, all fields return by default</param>
        /// <param name="status">Returns only the incidents currently in the passed status(es). Valid status options are triggered, acknowledged, and resolved</param>
        /// <param name="incident_key">Returns only the incidents with the passed de-duplication key</param>
        /// <param name="service">Returns only the incidents associated with the passed service(s). This expects one or more service IDs.  Separate multiple ids by a comma</param>
        /// <param name="assigned_to_user">Returns only the incidents currently assigned to the passed user(s). This expects one or more user IDs. </param>
        /// <param name="sort_by">Which field to sort by</param>
        /// <param name="sort_direction">Sort direction (default is asc)</param>
        /// <param name="offSet">The offset of the first incident record returned</param>
        /// <param name="limit">The number of incidents returned.</param>
        /// <returns></returns>
        public IncidentsResponse GetIncidents(IncidentFilter filters, IncidentSortBy sort_by, SortDirection sort_direction, int offSet, int limit) {
            var client = this.GetClient("/v1/incidents");
            var req = this.GetRequest();

            if (filters.ReturnAll) {
                req.AddParameter("date_range", "all");
            } 
            else {
                req.AddParameter("since", filters.since.ToString("s"));
                req.AddParameter("until", filters.until.ToString("s"));
            }
            
            if (!String.IsNullOrEmpty(filters.fields)) {
                req.AddParameter("fields", filters.fields);
            }

            if (!String.IsNullOrEmpty(filters.status)) {
                req.AddParameter("status", filters.fields);
            }

            if (!String.IsNullOrEmpty(filters.incident_key)) {
                req.AddParameter("incident_key", filters.incident_key);
            }

            if (!String.IsNullOrEmpty(filters.service)) {
                req.AddParameter("service", filters.service);
            }

            if (!String.IsNullOrEmpty(filters.assigned_to_user)) {
                req.AddParameter("assigned_to_user", filters.assigned_to_user);
            }

            if (sort_by != IncidentSortBy.unspecified) {
                req.AddParameter("sort_by", sort_by.ToString() + ":" + sort_direction.ToString());
            }
            
            req.AddParameter("offset", offSet);
            req.AddParameter("limit", limit);
            var resp = client.Execute<IncidentsResponse>(req);

            if (resp.Data == null) {
                throw new PagerDutyAPIException(resp);
            }

            return resp.Data;
        }
开发者ID:arlenyan,项目名称:PagerDuty.Net,代码行数:61,代码来源:PagerDutyAPI.cs

示例10: Users_GetByQuery

        public IEnumerable<UserBE> Users_GetByQuery(string usernamefilter, string realnamefilter, string usernameemailfilter, string rolefilter, bool? activatedfilter, uint? groupId, uint? serviceIdFilter, bool? seatFilter, SortDirection sortDir, UsersSortField sortField, uint? offset, uint? limit, out uint totalCount, out uint queryCount) {
            List<UserBE> users = new List<UserBE>();
            uint totalCountTemp = 0;
            uint queryCountTemp = 0;
            StringBuilder joinQuery = new StringBuilder();
            string sortFieldString;
            USERS_SORT_FIELD_MAPPING.TryGetValue(sortField, out sortFieldString);
            if(!string.IsNullOrEmpty(rolefilter) || (sortFieldString ?? string.Empty).StartsWith("roles.")) {
                joinQuery.Append(@"
left join roles
    on users.user_role_id = roles.role_id");
            }
            if((sortFieldString ?? string.Empty).StartsWith("services.")) {
                joinQuery.AppendFormat(@"
left join services
    on users.user_service_id = services.service_id");
            }
            if(groupId != null) {
                joinQuery.AppendFormat(@"
join groups
    on groups.group_id = {0}
join user_groups
    on user_groups.group_id = groups.group_id", groupId.Value);
            }
            StringBuilder whereQuery = new StringBuilder(" where 1=1");
            if(groupId != null) {
                whereQuery.AppendFormat(" AND users.user_id = user_groups.user_id");
            }
            if(!string.IsNullOrEmpty(usernamefilter) && !string.IsNullOrEmpty(realnamefilter)) {
                whereQuery.AppendFormat(" AND (user_name like '{0}%' OR user_real_name like '{1}%')", DataCommand.MakeSqlSafe(usernamefilter), DataCommand.MakeSqlSafe(realnamefilter));
            } else if(!string.IsNullOrEmpty(usernamefilter)) {
                whereQuery.AppendFormat(" AND user_name like '{0}%'", DataCommand.MakeSqlSafe(usernamefilter));
            } else if(!string.IsNullOrEmpty(realnamefilter)) {
                whereQuery.AppendFormat(" AND user_real_name like '{0}%'", DataCommand.MakeSqlSafe(realnamefilter));
            }
            if(!string.IsNullOrEmpty(usernameemailfilter)) {
                whereQuery.AppendFormat(" AND (user_name like '{0}%' OR user_email like '{0}%')", DataCommand.MakeSqlSafe(usernameemailfilter));
            }
            if(activatedfilter != null) {
                whereQuery.AppendFormat(" AND user_active = {0}", activatedfilter.Value ? "1" : "0");
            }
            if(!string.IsNullOrEmpty(rolefilter)) {
                whereQuery.AppendFormat(" AND role_name = '{0}'", DataCommand.MakeSqlSafe(rolefilter));
            }
            if(serviceIdFilter != null) {
                whereQuery.AppendFormat(" AND user_service_id = {0}", serviceIdFilter.Value);
            }
            if(seatFilter != null) {
                whereQuery.AppendFormat(" AND user_seat = {0}", seatFilter.Value ? 1 : 0);
            }

            StringBuilder sortLimitQuery = new StringBuilder();
            if(!string.IsNullOrEmpty(sortFieldString)) {
                sortLimitQuery.AppendFormat(" order by {0} ", sortFieldString);
                if(sortDir != SortDirection.UNDEFINED) {
                    sortLimitQuery.Append(sortDir.ToString());
                }
            }
            if(limit != null || offset != null) {
                sortLimitQuery.AppendFormat(" limit {0} offset {1}", limit ?? int.MaxValue, offset ?? 0);
            }
            string query = string.Format(@" /* Users_GetByQuery */
select *
from users
{0}
{1}
{2};
select count(*) as totalcount from users {0} {3};
select count(*) as querycount from users {0} {1};",
                joinQuery,
                whereQuery,
                sortLimitQuery,
                groupId == null ? string.Empty : "where users.user_id = user_groups.user_id");
            Catalog.NewQuery(query)
            .Execute(delegate(IDataReader dr) {
                while(dr.Read()) {
                    UserBE u = Users_Populate(dr);
                    users.Add(u);
                }
                if(dr.NextResult() && dr.Read()) {
                    totalCountTemp = DbUtils.Convert.To<uint>(dr["totalcount"], 0);
                }
                if(dr.NextResult() && dr.Read()) {
                    queryCountTemp = DbUtils.Convert.To<uint>(dr["querycount"], 0);
                }
            });
            totalCount = totalCountTemp;
            queryCount = queryCountTemp;
            return users;
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:90,代码来源:UserDA.cs

示例11: ConvertSortDirectionToSql

    private string ConvertSortDirectionToSql(SortDirection sortDirection)
    {
        string newSortDirection = String.Empty;
        string[] sortData = Session["sortExpression"].ToString().Trim().Split(' ');

        if (Session["NewSort"].ToString() == "true")
        {
            if (sortDirection.ToString() == sortData[0])
            {
                Session["sortExpression"] = "Descending";
                newSortDirection = "DESC";
            }
            else
            {
                Session["sortExpression"] = "Ascending";
                newSortDirection = "ASC";
            }
        }
        else
        {
            if (sortDirection.ToString() == sortData[0])
            {
                Session["sortExpression"] = "Ascending";
                newSortDirection = "ASC";
            }
            else
            {
                Session["sortExpression"] = "Descending";
                newSortDirection = "DESC";
            }
        }

        return newSortDirection;
    }
开发者ID:neuJMulholland,项目名称:PMsystem,代码行数:34,代码来源:Resources.aspx.cs

示例12: GetPagedList

        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<WeekSumInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< WeekSumInfo> list = new List< WeekSumInfo>();

            Query q = WeekSum .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            WeekSumCollection  collection=new  WeekSumCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (WeekSum  weekSum  in collection)
            {
                WeekSumInfo weekSumInfo = new WeekSumInfo();
                LoadFromDAL(weekSumInfo,   weekSum);
                list.Add(weekSumInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
开发者ID:xingfudaiyan,项目名称:OA,代码行数:32,代码来源:WeekSumInfo.cs

示例13: Services_GetByQuery

        public IList<ServiceBE> Services_GetByQuery(string serviceType, SortDirection sortDir, ServicesSortField sortField, uint? offset, uint? limit, out uint totalCount, out uint queryCount) {
            IList<ServiceBE> services = null;
            uint totalCountTemp = 0;
            uint queryCountTemp = 0;
            StringBuilder whereQuery = new StringBuilder(" where 1=1");
            if(!string.IsNullOrEmpty(serviceType)) {
                whereQuery.AppendFormat(" AND service_type = '{0}'", DataCommand.MakeSqlSafe(serviceType));
            }

            StringBuilder sortLimitQuery = new StringBuilder();
            string sortFieldString = null;
            
            //Sort by id if no sort specified.
            if(sortField == ServicesSortField.UNDEFINED) {
                sortField = ServicesSortField.ID;
            }
            if(SERVICES_SORT_FIELD_MAPPING.TryGetValue(sortField, out sortFieldString)) {
                sortLimitQuery.AppendFormat(" order by {0} ", sortFieldString);
                if(sortDir != SortDirection.UNDEFINED) {
                    sortLimitQuery.Append(sortDir.ToString());
                }
            } 
            if(limit != null || offset != null) {
                sortLimitQuery.AppendFormat(" limit {0} offset {1}", limit ?? int.MaxValue, offset ?? 0);
            }

            string query = string.Format(@" /* Services_GetByQuery */
select *
from services
{0}
{1};

select service_config.*
from service_config
join (
    select service_id
    from services
    {0}
    {1}
) s on service_config.service_id = s.service_id;

select service_prefs.*
from service_prefs
join (
    select service_id
    from services
    {0}
    {1}
) s on service_prefs.service_id = s.service_id;

select count(*) as totalcount from services;
select count(*) as querycount from services {0};
", whereQuery, sortLimitQuery);

            Catalog.NewQuery(query)
            .Execute(delegate(IDataReader dr) {
                services = Services_Populate(dr);

                if(dr.NextResult() && dr.Read()) {
                    totalCountTemp = DbUtils.Convert.To<uint>(dr["totalcount"], 0);
                }

                if(dr.NextResult() && dr.Read()) {
                    queryCountTemp = DbUtils.Convert.To<uint>(dr["querycount"], 0);
                }

            });

            totalCount = totalCountTemp;
            queryCount = queryCountTemp;

            return services == null ? new List<ServiceBE>() : services;
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:73,代码来源:ServicesDA.cs

示例14: GetOrderByClause

 private string GetOrderByClause(SortBy sortBy, SortDirection sortDirection, string articleAlias)
 {
     if (sortBy == SortBy.None)
     {
         return String.Empty;
     }
     else
     {
         switch (sortBy)
         {
             case SortBy.DateCreated:
             case SortBy.DateModified:
             case SortBy.DateOnline:
             case SortBy.Title:
                 return String.Format("order by {0}.{1} {2}", articleAlias, sortBy.ToString(), sortDirection.ToString());
             case SortBy.Category:
                 return String.Format("order by {0}.Category.Title {1}", articleAlias, sortDirection.ToString());
             case SortBy.CreatedBy:
                 return String.Format("order by {0}.CreatedBy.UserName {1}", articleAlias, sortDirection.ToString());
             case SortBy.ModifiedBy:
                 return String.Format("order by {0}.ModifiedBy.UserName {1}", articleAlias, sortDirection.ToString());
             default:
                 return String.Empty;
         }
     }
 }
开发者ID:martijnboland,项目名称:cuyahoga-1,代码行数:26,代码来源:ArticleDao.cs

示例15: GetPagedList

        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<ProductTypeInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< ProductTypeInfo> list = new List< ProductTypeInfo>();

            Query q = ProductType .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            ProductTypeCollection  collection=new  ProductTypeCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (ProductType  productType  in collection)
            {
                ProductTypeInfo productTypeInfo = new ProductTypeInfo();
                LoadFromDAL(productTypeInfo,   productType);
                list.Add(productTypeInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
开发者ID:xingfudaiyan,项目名称:OA,代码行数:32,代码来源:ProductTypeInfo.cs


注:本文中的SortDirection.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。