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


C# GenericRepository.Get方法代码示例

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


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

示例1: Index

        public ViewResult Index()
        {
            IList<Models.Nanny> nannies = null;

            var db = NannyContext.Create();
            GenericRepository<Models.Nanny> repository = new GenericRepository<Models.Nanny>(db);

            nannies = repository.Get().ToList();

            return View(nannies);
        }
开发者ID:NannyWeb,项目名称:Nanny,代码行数:11,代码来源:NannyController.cs

示例2: GetRefTerrain

        public REF_Terrain[] GetRefTerrain()
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var listRepository = new GenericRepository<REF_Terrain>(dataContext);

                IEnumerable<REF_Terrain> rtnList = listRepository
                    .Get();

                return rtnList.ToArray();
            }
        }
开发者ID:jeffyates123,项目名称:Au,代码行数:12,代码来源:RulesCatalogApiController.cs

示例3: GetRefStates

        public REF_States[] GetRefStates()
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var listRepository = new GenericRepository<REF_States>(dataContext);

                IEnumerable<REF_States> rtnList = listRepository
                    .Get()
                    .OrderBy(y => y.State);

                return rtnList.ToArray();
            }
        }
开发者ID:jeffyates123,项目名称:Au,代码行数:13,代码来源:RulesCatalogApiController.cs

示例4: GetMapCoordinates

        public DisplayCoordinate[][] GetMapCoordinates(string turnId)
        {
            var displayMapArray = new DisplayCoordinate[100][];

            using (var dataContext = new AusterlitzDbContext())
            {
                var turnMap = new GenericRepository<TR_MapCoordinates>(dataContext);
                var regionalMap = new GenericRepository<REF_PoliticalMapCoordinates>(dataContext);

                var turnCoordinateList = turnMap.GetItems(x => x.TurnId == turnId);
                var regionalCoordinateList = regionalMap.Get();
                var rulesCatalogApiController = new RulesCatalogApiController();

                var refProductionSites = rulesCatalogApiController.GetRefProductionSites();

                for (var y = 0; y <= 99; y++)
                {
                    displayMapArray[y] = new DisplayCoordinate[91];

                    for (var x = 0; x <= 90; x++)
                    {
                        var turnCoord = turnCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y);
                        var regionalCoord = regionalCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y);

                        if (turnCoord != null && regionalCoord != null)
                        {
                            displayMapArray[turnCoord.Y][turnCoord.X] = new DisplayCoordinate()
                            {
                                X = x,
                                Y = y,
                                TurnId = turnId,
                                Population = turnCoord.Population,
                                ProductionSite = turnCoord.ProductionSite.Replace(".",""),
                                State = turnCoord.State,
                                Bonus = regionalCoord.Bonus,
                                Owner = regionalCoord.Owner,
                                Terrain = regionalCoord.Terrain,
                            };

                            //displayMapArray[turnCoord.Y][turnCoord.X].allowableProdSites = calcAllowableProdSites(displayMapArray[turnCoord.Y][turnCoord.X], refProductionSites, state);

                        }
                        else
                        {
                            displayMapArray[y][x] = new DisplayCoordinate()
                            {
                                X = x,
                                Y = y,
                                TurnId = turnId,
                                Population = ".",
                                ProductionSite = " ",
                                State = " ",
                                Bonus = " ",
                                Owner = " ",
                                Terrain = " "
                            };
                        }

                        if (x == 0)
                            displayMapArray[y][x].Population = x.ToString();
                        else if (y == 0)
                            displayMapArray[y][x].Population = y.ToString();

                    }
                }
                return displayMapArray;
            }
        }
开发者ID:jeffyates123,项目名称:Au,代码行数:68,代码来源:TurnReportApiController.cs

示例5: Get_With_NULL_Filter_Must_Return__All

        public void Get_With_NULL_Filter_Must_Return__All()
        {
            //
            // Arrange
            //
            var models = Enumerable.Range(1, 10).Select(x =>
            {
                var mockModel = new Mock<IModel>();
                mockModel.Setup(y => y.Id).Returns(x);

                return mockModel.Object;

            }).AsQueryable();

            var mockDbSet = new Mock<DbSet<IModel>>();
            mockDbSet.As<IQueryable<IModel>>().Setup(m => m.Provider).Returns(models.Provider);
            mockDbSet.As<IQueryable<IModel>>().Setup(m => m.Expression).Returns(models.Expression);
            mockDbSet.As<IQueryable<IModel>>().Setup(m => m.ElementType).Returns(models.ElementType);
            mockDbSet.As<IQueryable<IModel>>().Setup(m => m.GetEnumerator()).Returns(models.GetEnumerator());

            var mockContext = new Mock<EFDbContext>();

            mockContext.Setup(x => x.Set<IModel>()).Returns(mockDbSet.Object);

            var repository = new GenericRepository<IModel>(mockContext.Object);

            Expression<Func<IModel, bool>> filterExpression = null;
            //
            // Act
            //
            var results = repository.Get(filterExpression);
            //
            // Assert
            //
            Assert.IsNotNull(results);
            Assert.IsNotNull(results.First());
            Assert.AreEqual(10, results.Count());
            Assert.AreEqual(1, results.First().Id);
        }
开发者ID:Cheranga,项目名称:DAL,代码行数:39,代码来源:GenericRepositoryTest.cs

示例6: GetProvinces

 public List<Location> GetProvinces()
 {
     GenericRepository<Location> locationRepo = new GenericRepository<Location>();
     return locationRepo.Get(l => l.ParentId == -1).ToList();
 }
开发者ID:yigityesilpinar,项目名称:Web-Based-Application-of-Carpooling,代码行数:5,代码来源:LocationController.cs

示例7: GetDistrictsByProvince

 public List<Location> GetDistrictsByProvince(int provinceId)
 {
     GenericRepository<Location> locationRepo = new GenericRepository<Location>();
     return locationRepo.Get(l => l.ParentId == provinceId).ToList();
 }
开发者ID:yigityesilpinar,项目名称:Web-Based-Application-of-Carpooling,代码行数:5,代码来源:LocationController.cs

示例8: AddLanguageSkill

        public async Task<ActionResult> AddLanguageSkill([Bind(Include = "IdNanny, IdLanguage, IdLanguageLevel")] LanguageSkill model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return PartialView("Profile");
                }

                model.DateCreated = DateTime.UtcNow;
                model.DateLastUpdated = DateTime.UtcNow;

                GenericRepository<LanguageSkill> repositoryqLanguageSkill = new GenericRepository<LanguageSkill>(new NannyContext());

                repositoryqLanguageSkill.Insert(model);
                repositoryqLanguageSkill.Save();

                IEnumerable<LanguageSkill> languages = repositoryqLanguageSkill.Get().Where(l => l.IdNanny == model.IdNanny).ToList();

                ViewBag.LanguageSkills = languages;

                return GetMenu("LanguageSkill");
            }
            catch (DataException dex)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return View(model);
        }
开发者ID:NannyWeb,项目名称:Nanny,代码行数:30,代码来源:NannyController.cs

示例9: LanguageSkill_List

        //[ActionName("LanguageSkill_Edit")]
        //public PartialViewResult LanguageSkill_Edit(Int64 idNanny)
        //{
        //    LanguageSkill model = new Models.LanguageSkill();
        //    model.IdNanny = idNanny;

        //    ViewBag.Languages = new GenericRepository<Language>(new NannyDBContext()).Get();
        //    ViewBag.LanguageLevels = new GenericRepository<LanguageLevel>(new NannyDBContext()).Get();

        //    return PartialView(model);
        //}

        public ActionResult LanguageSkill_List()
        {
            GenericRepository<LanguageSkill> repositoryqLanguageSkill = new GenericRepository<LanguageSkill>(new NannyContext());
            IEnumerable<LanguageSkill> languages = repositoryqLanguageSkill.Get().Where(l => l.IdNanny == Guid.NewGuid()).ToList();

            ViewBag.LanguageSkills = languages;

            return PartialView("LanguageSkill_List", languages);
        }
开发者ID:NannyWeb,项目名称:Nanny,代码行数:21,代码来源:NannyController.cs


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