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


C# Repository.All方法代码示例

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


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

示例1: AutoUpdateArsenalMatchResult_Test

        public void AutoUpdateArsenalMatchResult_Test()
        {
            try
            {
                IRepository repo = new Repository();

                var cmList = repo.All<CasinoMatch>();
                var mList = repo.All<ArsenalMatch>();

                if (mList != null && mList.Count > 0 && cmList != null && cmList.Count > 0)
                {
                    foreach (var m in mList)
                    {
                        CasinoMatch cm;

                        if (m.CasinoMatchGuid.HasValue)
                        {
                            //Casino MatchGuid Bound
                            cm = cmList.Find(x => x.ID.Equals(m.CasinoMatchGuid.Value));
                        }
                        else
                        {
                            //new Arsenal Match
                            cm = cmList.Find(x =>
                            {
                                if (m.IsHome)
                                {
                                    return m.TeamGuid.Equals(x.Away) && m.PlayTime.Equals(x.PlayTime);
                                }
                                return m.TeamGuid.Equals(x.Home) && m.PlayTime.Equals(x.PlayTime);
                            });
                        }

                        if (cm != null && cm.ResultHome.HasValue && cm.ResultAway.HasValue)
                        {
                            if (m.ResultHome.Equals(cm.ResultHome) && m.ResultAway.Equals(cm.ResultAway)
                                && m.PlayTime.Equals(cm.PlayTime) && m.CasinoMatchGuid.Equals(cm.ID))
                            {
                                continue;
                            }

                            m.ResultHome = cm.ResultHome;
                            m.ResultAway = cm.ResultAway;
                            m.PlayTime = cm.PlayTime;
                            m.CasinoMatchGuid = cm.ID;

                            repo.Update(m);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
开发者ID:CyranoChen,项目名称:Arsenalcn,代码行数:56,代码来源:AcnCasinoTest.cs

示例2: AutoUpdateMemberType_Test

        public void AutoUpdateMemberType_Test()
        {
            try
            {
                IRepository repo = new Repository();

                var mlist = repo.All<Member>().FindAll(x => (int)x.MemberType <= 2);
                var olist = repo.All<Order>().FindAll(x => x.IsActive);

                if (mlist.Count > 0 && olist.Count > 0)
                {
                    // Don't place LINQ to Foreach, first ToList(), then use list.FindAll to improve performance
                    foreach (var m in mlist)
                    {
                        MemberType type;
                        var list = olist.FindAll(x => x.MemberID == m.ID);

                        // Refresh the MemberType of instance
                        if (list.Count > 0)
                        {
                            if (list.Exists(x => x.OrderType == OrderBaseType.Ticket || x.OrderType == OrderBaseType.Travel))
                            {
                                type = MemberType.Match;
                            }
                            else if (list.Exists(x => x.OrderType == OrderBaseType.ReplicaKit ||
                                x.OrderType == OrderBaseType.Printing || x.OrderType == OrderBaseType.Wish))
                            {
                                type = MemberType.Buyer;
                            }
                            else
                            {
                                type = MemberType.None;
                            }
                        }
                        else
                        {
                            type = MemberType.None;
                        }

                        if (!m.MemberType.Equals(type))
                        {
                            m.MemberType = type;

                            repo.Update(m);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
开发者ID:CyranoChen,项目名称:Arsenalcn,代码行数:53,代码来源:AutoUpdateMemberTypeTest.cs

示例3: Test_All_Pager

        public void Test_All_Pager()
        {
            IRepository repo = new Repository();

            // normal condition
            IPager pager1 = new Pager(1) { PagingSize = 10 };

            Assert.IsFalse(pager1.TotalCount > 0);

            var query1 = repo.All<League>(pager1, "LeagueOrder, LeagueOrgName");
            var queryVal = repo.All<League>();

            Assert.IsNotNull(query1);
            Assert.IsInstanceOfType(query1, typeof(List<League>));
            Assert.IsTrue(query1.Any());

            Assert.IsTrue(pager1.TotalCount > 0);
            Assert.AreEqual(pager1.TotalCount.ToString(), queryVal.Count.ToString());
            Assert.AreEqual(pager1.PagingSize.ToString(), query1.Count.ToString());

            Assert.IsTrue(query1[0].Equals(queryVal[10]));

            // large pagingSize
            IPager pager2 = new Pager(0) { PagingSize = 1000 };

            var query2 = repo.All<League>(pager2, "LeagueOrder, LeagueOrgName");

            Assert.IsNotNull(query2);
            Assert.IsInstanceOfType(query2, typeof(List<League>));
            Assert.IsTrue(query2.Any());

            Assert.IsTrue(pager2.TotalCount > 0);
            Assert.AreEqual(pager2.TotalCount.ToString(), queryVal.Count.ToString());
            Assert.AreEqual(query2.Count.ToString(), queryVal.Count.ToString());

            // max currentPage
            IPager pager3 = new Pager(1000) { PagingSize = 20 };

            var query3 = repo.All<League>(pager3, "LeagueOrder, LeagueOrgName");

            Assert.IsNotNull(query3);
            Assert.IsInstanceOfType(query3, typeof(List<League>));
            Assert.IsTrue(query3.Any());

            Assert.IsTrue(pager2.TotalCount > 0);
            Assert.AreEqual(pager2.TotalCount.ToString(), queryVal.Count.ToString());
            Assert.AreEqual(pager3.CurrentPage.ToString(), pager3.MaxPage.ToString());
            Assert.AreEqual(query3.Count.ToString(), (queryVal.Count % pager3.PagingSize).ToString());
        }
开发者ID:CyranoChen,项目名称:Arsenalcn,代码行数:49,代码来源:RepositoryTest.cs

示例4: Execute

        public void Execute(object state)
        {
            var logInfo = new LogInfo
            {
                MethodInstance = MethodBase.GetCurrentMethod(),
                ThreadInstance = Thread.CurrentThread
            };

            try
            {
                _log.Info("Scheduler Start: (AutoUpdateActiveBankerCash)", logInfo);

                IRepository repo = new Repository();

                var list = repo.All<Banker>().FindAll(x => x.IsActive);

                foreach (var b in list)
                {
                    b.Statistic();
                }

                _log.Info("Scheduler End: (AutoUpdateActiveBankerCash)", logInfo);
            }
            catch (Exception ex)
            {
                _log.Warn(ex, logInfo);
            }
        }
开发者ID:CyranoChen,项目名称:Arsenalcn,代码行数:28,代码来源:AutoUpdateActiveBankerCash.cs

示例5: Execute

        public void Execute(object state)
        {
            var logInfo = new LogInfo
            {
                MethodInstance = MethodBase.GetCurrentMethod(),
                ThreadInstance = Thread.CurrentThread
            };

            try
            {
                log.Info("Scheduler Start: (AutoUpdateActiveCasinoItemEarning)", logInfo);

                IRepository repo = new Repository();

                var list = repo.All<CasinoItem>().FindAll(x =>
                    x.ItemType.Equals(CasinoType.SingleChoice) && x.Earning.HasValue);

                foreach (var c in list)
                {
                    c.Statistics();
                }

                log.Info("Scheduler End: (AutoUpdateActiveCasinoItemEarning)", logInfo);
            }
            catch (Exception ex)
            {
                log.Warn(ex, logInfo);
            }
        }
开发者ID:CyranoChen,项目名称:Arsenalcn,代码行数:29,代码来源:AutoUpdateActiveCasinoItemEarning.cs

示例6: QueryAll

 public void QueryAll()
 {
     var session = GetConnection().CreateSession(_DatabaseName);
     var repository = new Repository<ProductTranslation>(session);
     var savedProducts = repository.All();
     savedProducts.ToList().ForEach(Console.WriteLine);
 }
开发者ID:g0t4,项目名称:Presentations,代码行数:7,代码来源:Demos.cs

示例7: EntriesCount

 public int EntriesCount()
 {
     using (var repository = new Repository<Entry>())
     {
         return repository.All().Count();
     }
 }
开发者ID:niekert,项目名称:GoBlog,代码行数:7,代码来源:EntryService.cs

示例8: Execute

        public void Execute(object state)
        {
            var logInfo = new LogInfo
            {
                MethodInstance = MethodBase.GetCurrentMethod(),
                ThreadInstance = Thread.CurrentThread
            };

            try
            {
                _log.Info("Scheduler Start: (AutoUpdateOrderType)", logInfo);

                IRepository repo = new Repository();

                var oList = repo.All<Order>();
                var oiList = repo.All<OrderItem>().FindAll(x => Product.Cache.Load(x.ProductGuid) != null);

                if (oList.Count > 0 && oiList.Count > 0)
                {
                    // Don't place LINQ to Foreach, first ToList(), then use list.FindAll to improve performance
                    foreach (var o in oList)
                    {
                        var list = oiList.FindAll(x => x.OrderID.Equals(o.ID));

                        // Refresh the OrderType of instance
                        if (list.Count > 0)
                        {
                            var type = Order.GetOrderTypeByOrderItems(list);

                            if (!o.OrderType.Equals(type))
                            {
                                o.OrderType = type;

                                repo.Update(o);
                            }
                        }
                    }
                }

                _log.Info("Scheduler End: (AutoUpdateOrderType)", logInfo);
            }
            catch (Exception ex)
            {
                _log.Warn(ex, logInfo);
            }
        }
开发者ID:CyranoChen,项目名称:Arsenalcn,代码行数:46,代码来源:AutoUpdateOrderType.cs

示例9: Test_All

        public void Test_All()
        {
            IRepository repo = new Repository();

            var query = repo.All<League>();

            Assert.IsNotNull(query);
            Assert.IsInstanceOfType(query, typeof(List<League>));
            Assert.IsTrue(query.Any());
        }
开发者ID:CyranoChen,项目名称:Arsenalcn,代码行数:10,代码来源:RepositoryTest.cs

示例10: List

 public List<Entry> List()
 {
     using (var repository = new Repository<Entry>())
     {
         return
             repository
                 .All()
                 .OrderByDescending(e => e.PublishedAt).ToList();
     }
 }
开发者ID:niekert,项目名称:GoBlog,代码行数:10,代码来源:EntryService.cs

示例11: PopulateForm

 private void PopulateForm()
 {
     DataLayer.SessionHelper _sessionHelper = new SessionHelper();
     Repository<Guid, NewsItem> _newsItemRepo = new Repository<Guid, NewsItem>(_sessionHelper.GetSession("APL"));
     UnitOfWork _unitOfWork = new UnitOfWork(_sessionHelper.GetSessionFactory("APL"));
     var newsItems = _newsItemRepo.All().ToList();
     dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     dataGridView1.CellContentDoubleClick += DataGridView1_CellContentDoubleClick;
     dataGridView1.ReadOnly = true;
     dataGridView1.DataSource = newsItems;
 }
开发者ID:themanowar77,项目名称:myaplwin,代码行数:11,代码来源:NewsEdit.cs

示例12: Create

        public static BoxerNameConstraint Create()
        {
            var session = Configure.GetSessionFactory().OpenSession();
            var repository = new Repository<Boxer>(session);
            var allNames = repository.All().Select(x => (x.FirstName.Replace(" ", "_") + "-" + x.LastName.Replace(" ", "_")).ToLowerInvariant()).ToArray();

            session.Flush();
            session.Dispose();

            return new BoxerNameConstraint(allNames);
        }
开发者ID:elmo61,项目名称:BritBoxing,代码行数:11,代码来源:BoxerNameConstraint.cs

示例13: DecklistByDate

 public void DecklistByDate()
 {
     var targetDate = new DateTime(2014, 01, 01);
     var decklistByDates = new Repository().GetDecklistForDay(targetDate);
     Assert.IsNotNull(decklistByDates);
     Assert.IsTrue(decklistByDates.All(a =>
     {
         var parseDate = DateTime.Parse(a.Creation);
         return (parseDate >= targetDate && parseDate <= parseDate.AddDays(1).AddMinutes(-1));
     }));
 }
开发者ID:keldren,项目名称:NetrunnerDb.Net,代码行数:11,代码来源:QueryThings.cs

示例14: GetAllStaff

 public void GetAllStaff()
 {
     var repo = new Repository<FieldStaff>(DataService.GetSession());
     var staff = repo.All();
     Assert.NotNull(staff);
     foreach (var staffMember in staff)
     {
         Assert.NotNull(staffMember);
         Assert.NotNull(staffMember.StaffCode);
     }
 }
开发者ID:spc-ofp,项目名称:LegacyObserverDataAccessLayer,代码行数:11,代码来源:TestFieldStaff.cs

示例15: PaginatedList

        public PagedList<Entry> PaginatedList(int pageNumber, int pageSize)
        {
            using (var repository = new Repository<Entry>())
            {
                var entries =
                    repository
                        .All()
                        .OrderByDescending(e => e.PublishedAt);

                return entries.ToPagedList(pageNumber, pageSize);
            }
        }
开发者ID:niekert,项目名称:GoBlog,代码行数:12,代码来源:EntryService.cs


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