欲善其事,必利其器 - Librame Utility 3.5.1 正式发布(第一个里程碑版本)


更新日志:

1、完善 HQL 数据查询(增加流式查询)功能,支持对指定字段进行查询。

例如:读取文章表的标题与发布日期字段列,并按发布日期进行降序排列(程序自行转换为对应实体)。

 

第一种:手写配置

 

var queryBuilder =  new HQLEntityQueryBuilder( " ArticleEntity ")
                .SetSelects( " Title,Pubdate ")
                .SetOrders( " Pubdate ").SetOrderby(DataOrderby.Desc);

 

第二种:Lambda 表达式配置

 

var queryBuilder =  new HQLEntityQueryBuilder<ArticleEntity>()
                .SetSelect(a => a.Title).SetSelect(a => a.Pubdate)
                .SetOrder(a => a.Pubdate).SetOrderby(DataOrderby.Desc);

 

执行查询,并输出列表

 

//  输出列表
WriteList(ArticleBll.TopList( 6, queryBuilder));

 

运行效果

 

分页数据效果

 

2、支持多表关联查询

例如:读取文章表的标题、序号与文章统计表的浏览次数字段列,并按浏览次数进行降序排列。

 

var queryBuilder =  new HQLEntityQueryBuilder<ArticleEntity>()
                .SetSelects( " Title,Articleid,View.Count ")
                .SetOrders( " View.Count ").SetOrderby(DataOrderby.Desc);

 

执行查询,并输出列表

 

//  获取前2条数据
var list2 = ArticleBll.TopList( 2, queryBuilder);
             //  独立输出
            list2.TryEach((i2, li2) =>
            {
                 if (i2 == list2.Count -  1)
                    Response.TestParagraphLine( " 标题 / 编号 / 人气 ", li2.Title +  "  /  " + li2.Articleid +  "  /  " + li2.View.Count);
                 else
                    Response.TestLine( " 标题 / 编号 / 人气 ", li2.Title +  "  /  " + li2.Articleid +  "  /  " + li2.View.Count);
            });

 

运行效果

 

 

3、前台呈现(结合 jQuery、jQuery-UI 实现异步读取,异步分页等效果;浏览器为IE9)

 

<div>
                    <!-- UL/LI -->
                    <ul id= " first_test "  class= " list ">
                        <li><h3 style= " display:inline; ">这是标题</h3><span style= " margin-left:10px; ">这是时间</span></li>
                    </ul>
                    <script type= " text/javascript ">
                        function firstRenderListTest(i, entity) {
                             var demo =  ' <li> ';
                            demo +=  ' <h3 style="display:inline;"> ' + entity.Title +  ' </h3> ';
                            demo +=  ' <span style="margin-left:10px;"> ' + entity.Pubdate +  ' </span> ';
                            demo +=  ' </li> ';
                             return demo;
                        };

                         var selects =  " Title,Pubdate ";
                         var orders =  " Pubdate ";

                        $( " #first_test ").dataList( " ArticleEntity ",
                            { size:  6, selects: selects, orders: orders  /*  ,orderby: "desc/asc"(默认为倒序)  */ },
                            firstRenderListTest);
                    </script>
                </div>

 

页面预览效果

异步分页

 

<div id= " tabs-1 ">
                <ul id= " four_test "  class= " list ">
                    <li><h3 style= " display:inline; ">这是标题</h3><span style= " margin-left:10px; ">这是时间</span></li>
                </ul>
                <div id= " four_paging ">
                    Loading...
                </div>

                <script type= " text/javascript ">
                    function fourRenderListTest(i, entity) {
                         var demo =  ' <li> ';
                        demo +=  ' <h3 style="display:inline;"> ' + entity.Title +  ' </h3> ';
                        demo +=  ' <span style="margin-left:10px;"> ' + entity.Pubdate +  ' </span> ';
                        demo +=  ' </li> ';
                         return demo;
                    };

                    function fourPagingList(index) {
                         var entityName =  " ArticleEntity ";
                         var selects =  " Title,Pubdate ";
                         // var wheres = [{ Key: "Articleid", Value: "1", Type: "int", Compare: "Equals"}];
                         var orders =  " Pubdate ";

                         var options = {
                            size:  6, index: index, selects: selects, orders: orders, paging:  " true "  // , wheres: wheres
                        };

                         //  数据列表
                        $( " #four_test ").dataList(entityName, options, fourRenderListTest);
                         //  分页
                        $( " #four_paging ").paging(entityName, options, function (i) {
                             return  " javascript:fourPagingList( " + i +  " ); ";
                        });
                    };

                    fourPagingList( 1);
                </script>
            </div>

 

页面预览效果

 

第二页异步加载效果

异步加载完成效果

 

多表关联查询

 

<div id= " tabs-2 ">
                <dl id= " five_test "  class= " list ">
                    <dd><h3 style= " display:inline; ">这是标题</h3><span style= " margin-left:10px; ">这是浏览次数</span></dd>
                </dl>
                <script type= " text/javascript ">
                    function fiveRenderListTest(i, entity) {
                         var demo =  ' <li> ';
                        demo +=  ' <h3 style="display:inline;"> ' + entity.Title +  ' </h3> ';
                        demo +=  ' <span style="margin-left:10px;"> ' + entity.View.Count +  ' </span> ';
                        demo +=  ' </li> ';
                         return demo;
                    };

                     var selects =  " Title,View.Count ";
                     var orders =  " View.Count ";

                    $( " #five_test ").dataList( " ArticleEntity ",
                        { size:  2, selects: selects, orders: orders },
                        fiveRenderListTest);
                </script>
            </div>

 

页面预览效果

 

浏览器兼容性测试(Google Chrome 17.0.963.78)

 

更换主题效果

 

 

Librame Utility 开源项目组(http://librame.codeplex.com/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM