コード例 #1
0
        public string GetSqlForSelectBuilder(BuilderData data)
        {
            var sql = "";

            sql  = "select " + data.Select;
            sql += " from " + data.From;
            if (data.WhereSql.Length > 0)
            {
                sql += " where " + data.WhereSql;
            }
            if (data.GroupBy.Length > 0)
            {
                sql += " group by " + data.GroupBy;
            }
            if (data.Having.Length > 0)
            {
                sql += " having " + data.Having;
            }
            if (data.OrderBy.Length > 0)
            {
                sql += " order by " + data.OrderBy;
            }
            if (data.PagingItemsPerPage > 0)
            {
                if (data.PagingItemsPerPage > 0)
                {
                    sql += " limit " + data.PagingItemsPerPage;
                }
                sql += " offset " + (data.GetFromItems() - 1);
            }


            return(sql);
        }
コード例 #2
0
        public string GetSqlForSelectBuilder(BuilderData data)
        {
            var sql = "";

            sql  = "select " + data.Select;
            sql += " from " + data.From;
            if (data.WhereSql.Length > 0)
            {
                sql += " where " + data.WhereSql;
            }
            if (data.GroupBy.Length > 0)
            {
                sql += " group by " + data.GroupBy;
            }
            if (data.Having.Length > 0)
            {
                sql += " having " + data.Having;
            }
            if (data.OrderBy.Length > 0)
            {
                sql += " order by " + data.OrderBy;
            }
            if (data.PagingItemsPerPage > 0 &&
                data.PagingCurrentPage > 0)
            {
                sql += string.Format(" limit {0}, {1}", data.GetFromItems() - 1, data.GetToItems());
            }

            return(sql);
        }
コード例 #3
0
        public string GetSqlForSelectBuilder(BuilderData data)
        {
            var sql = "";

            if (data.PagingItemsPerPage == 0)
            {
                sql  = "select " + data.Select;
                sql += " from " + data.From;
                if (data.WhereSql.Length > 0)
                {
                    sql += " where " + data.WhereSql;
                }
                if (data.GroupBy.Length > 0)
                {
                    sql += " group by " + data.GroupBy;
                }
                if (data.Having.Length > 0)
                {
                    sql += " having " + data.Having;
                }
                if (data.OrderBy.Length > 0)
                {
                    sql += " order by " + data.OrderBy;
                }
            }
            else if (data.PagingItemsPerPage > 0)
            {
                sql += " from " + data.From;
                if (data.WhereSql.Length > 0)
                {
                    sql += " where " + data.WhereSql;
                }
                if (data.GroupBy.Length > 0)
                {
                    sql += " group by " + data.GroupBy;
                }
                if (data.Having.Length > 0)
                {
                    sql += " having " + data.Having;
                }

                sql = string.Format(@"with PagedPersons as
										(
											select top 100 percent {0}, row_number() over (order by {1}) as FLUENTDATA_ROWNUMBER
											{2}
										)
										select *
										from PagedPersons
										where fluentdata_RowNumber between {3} and {4}"                                        ,
                                    data.Select,
                                    data.OrderBy,
                                    sql,
                                    data.GetFromItems(),
                                    data.GetToItems());
            }

            return(sql);
        }