Esempio n. 1
0
        protected EntityList FetchBy(LinqCountByBookNameCriteria criteria)
        {
            var q = this.CreateLinqQuery();

            q = q.Where(c => c.Book.Name == criteria.Name);

            var count = q.Count();
            var list  = new ChapterList();

            list.SetTotalCount(count);

            return(list);
        }
Esempio n. 2
0
        public void ORM_AggtSQL_LoadEntities()
        {
            using (RF.TransactionScope(UnitTestEntityRepositoryDataProvider.DbSettingName))
            {
                var so = new SectionOwner();
                RF.Save(so);

                var book = CreateAggtBook(so);
                RF.Save(book);

                var api = AggregateSQL.Instance;

                var loadOptions = api
                    .BeginLoadOptions<Chapter>().LoadChildren(c => c.SectionList)
                    .Order<Section>().By(p => p.Name)
                    //.Continue<PBSProperty>()
                    .LoadFK(p => p.SectionOwner);

                var sql = api.GenerateQuerySQL(loadOptions, book.Id);
                var sql2 = api.GenerateQuerySQL(loadOptions, string.Format("Chapter.BookId = {0}", book.Id));

                Assert.AreEqual(sql, sql2);

                //聚合加载整个对象树。
                var entities = new ChapterList();
                api.LoadEntities(entities, sql, loadOptions);

                //无懒加载测试。
                var count = Logger.DbAccessedCount;
                foreach (Chapter chapter in entities)
                {
                    foreach (Section section in chapter.SectionList)
                    {
                        var so2 = section.SectionOwner;
                    }
                }
                Assert.IsTrue(Logger.DbAccessedCount == count, "由于数据已经全部加载完成,所以这里不会发生懒加载。");
            }
        }
Esempio n. 3
0
 public void ORM_AggtSQL_LoadSingleChild()
 {
     var bookId = 0;
     var sqlSimple = AggregateSQL.Instance.GenerateQuerySQL<Chapter>(
         option => option.LoadChildren(c => c.SectionList),
         bookId
         );
     var list = new ChapterList();
     AggregateSQL.Instance.LoadEntities<Chapter>(list,
         option => option.LoadChildren(c => c.SectionList),
         bookId
         );
 }