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


C# Repository.Find方法代码示例

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


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

示例1: add

        public static Result add(School school)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var repo = new Repository<School>(db);
                    var sch = repo.Find(d => d.Ad == school.Ad && d.IsDeleted == false);
                    var schmeb = repo.Find(d => d.MebKodu == school.MebKodu && d.IsDeleted == false);

                    if (sch.Count() > 0)
                    {
                        result = new Result(SystemRess.Messages.hata_ayniOkulSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return result;
                    }
                    else if (schmeb.Count() > 0)
                    {
                        result = new Result(SystemRess.Messages.hata_ayniMebKoduSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return result;
                    }
                    repo.Add(school);
                    result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
                    return result;
                }
                catch (Exception)
                {
                    result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
                    return result;
                }
            }
        }
开发者ID:sakurahoshi,项目名称:appointment,代码行数:31,代码来源:SchoolManager.cs

示例2: Should_Save_a_Job

        public void Should_Save_a_Job()
        {
            var fixture = new Fixture();
            var job = fixture.Build<Job>()
                .Without(c => c.Id)
                .CreateAnonymous();
            using (var saveContext = DbContext())
            {
                var repo = new Repository<Job>(saveContext);
                repo.InsertOrUpdate(job);
                repo.Save();
            }

            Job savedJob;
            using (var readContext = DbContext())
            {
                var repo1 = new Repository<Job>(readContext);
                savedJob = repo1.Find(job.Id);
            }
            //            savedJob.Id.ShouldEqual(1);
            var compare = new KellermanSoftware.CompareNetObjects.CompareObjects();

            // savedJob is a proxy
            compare.MaxDifferences = 1;

            compare.Compare(job, savedJob);
            (compare.Differences.Count <= 1).ShouldBeTrue();

            Debug.WriteLine(compare.DifferencesString);
        }
开发者ID:erichexter,项目名称:TestSwarm,代码行数:30,代码来源:JobRepositoryTest.cs

示例3: Main

        static void Main(string[] args)
        {
            var context = new DataContext("Data Source=(local);Initial Catalog=GettingStarted;Integrated Security=true;", new GettingStartedMappings());
            var repository = new Repository(context);

            IEnumerable<Person> results = repository.Find(new FindPersonByLastNameEmbeddedSQLQuery("Liles"));
        }
开发者ID:calebjenkins,项目名称:Highway.Data,代码行数:7,代码来源:Program.cs

示例4: Integration_LogDataContext_LogResository_Log_Find_Return_Log

        public void Integration_LogDataContext_LogResository_Log_Find_Return_Log()
        {
            Logqso.mvc.Entities.LogDataEntity.Log Log1 = null;
            // context object LogDataContext matches the same name used for LogqsoData DB
            using (IDataContextAsync context = new ContestqsoDataContext())
            //IUnitOfWorkDataAsync and UnitOfWorkData are used in order for Dependency Injection to inject the DataDB
            using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
            {
                bool caught = false;
                IRepositoryAsync<Logqso.mvc.Entities.LogDataEntity.Log> _logRepository = new Repository<Log>(context, unitOfWork);

                try
                {
                    Log1 = _logRepository.Find(LogId);
                }
                catch (Exception ex)
                {
                    TestContext.WriteLine(string.Format("Integration_LogDataContext_LogResository_Log_Find_Return_Log exception {0}",ex.Message) );

                    caught = true;
                }
                Assert.IsFalse(caught);  //exception
                Assert.IsNotNull(Log1);
                Assert.IsInstanceOfType(Log1, typeof(Logqso.mvc.Entities.LogDataEntity.Log));
                Assert.AreEqual( LogId, Log1.LogId );
                Assert.IsInstanceOfType(Log1.ContestYear, typeof(DateTime));
                Assert.AreEqual(1, Log1.CallsignId );

            }
        }
开发者ID:psws,项目名称:logqso.mvc,代码行数:30,代码来源:IntegrationDataRepositoryTests.cs

示例5: CreateUser

        public static Result CreateUser(User newUser)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var userRepository = new Repository<User>(db);
                    var user = userRepository.Find(d => d.TCKimlik == newUser.TCKimlik);

                    if (user.Count() < 1)
                    {
                        if (string.IsNullOrEmpty(newUser.Sifre))
                        {
                            newUser.Sifre = newUser.TCKimlik.ToString();
                        }

                        userRepository.Add(newUser);
                        result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
                        return result;
                    }
                    else
                    {
                        result = new Result(SystemRess.Messages.hata_ayniTcSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return result;
                    }
                }
                catch (Exception)
                {
                    result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
                    return result;
                }
            }
        }
开发者ID:sakurahoshi,项目名称:appointment,代码行数:33,代码来源:UserManager.cs

示例6: Login

        public static User Login(Int64 tckimlikno, string password)
        {
            using (SGContext db = new SGContext())
            {
                var userRepository = new Repository<User>(db);
                var us = userRepository.Find(d => d.TCKimlik == tckimlikno && d.Sifre == password);

                if (us.Count() > 0)
                {
                    User record = new User();
                    SG_DAL.Enums.EnumRol rol = (SG_DAL.Enums.EnumRol)(us.FirstOrDefault().Rol);

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, us.FirstOrDefault().Ad + " " + us.FirstOrDefault().Soyad, DateTime.Now, DateTime.Now.AddMinutes(120), false, rol.ToString(), FormsAuthentication.FormsCookiePath);
                    string encTicket = FormsAuthentication.Encrypt(ticket);
                    HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                    if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
                    HttpContext.Current.Response.Cookies.Add(cookie);

                    HttpCookie myCookie = new HttpCookie("LoginCookie");
                    myCookie["tcno"] = us.FirstOrDefault().TCKimlik.ToString();
                    myCookie.Expires = DateTime.Now.AddDays(1d);
                    HttpContext.Current.Response.Cookies.Add(myCookie);

                    return us.FirstOrDefault();
                }
                else
                    return null;

            }
        }
开发者ID:sakurahoshi,项目名称:appointment,代码行数:30,代码来源:AccountManager.cs

示例7: Delete

 public void Delete(string slug)
 {
     using (var repository = new Repository<Entry>())
     {
         var entry = repository.Find(slug);
         repository.Delete(entry);
     }
 }
开发者ID:niekert,项目名称:GoBlog,代码行数:8,代码来源:EntryService.cs

示例8: Find_WithCriteria_ThrowsNotImplementedException

        public void Find_WithCriteria_ThrowsNotImplementedException(Mock<IUnitOfWork> unitOfWork)
        {
            // Given
            var sut = new Repository<object>(unitOfWork.Object);

            // Then
            Assert.Throws<NotImplementedException>(() => sut.Find(i => true));
        }
开发者ID:ecampidoglio,项目名称:Expresso,代码行数:8,代码来源:RepositoryTest.cs

示例9: Should_return_correct_number_of_records_based_on_criteria

        public void Should_return_correct_number_of_records_based_on_criteria()
        {
            using (var context = new RepositoryTestDataContext())
            {
                var repo = new Repository<Order>(context);

                Assert.AreEqual(3, repo.Find(o => o.CustomerID == "VINET").Count());
            }
        }
开发者ID:NathanGloyn,项目名称:Generic-Repository,代码行数:9,代码来源:When_finding_records.cs

示例10: Should_return_empty_enumerable_where_no_records_match_criteria

        public void Should_return_empty_enumerable_where_no_records_match_criteria()
        {
            using (var context = new RepositoryTestDataContext())
            {
                var repo = new Repository<Order>(context);

                CollectionAssert.IsEmpty(repo.Find(o => o.CustomerID == "NoMatch"));
            }
        }
开发者ID:NathanGloyn,项目名称:Generic-Repository,代码行数:9,代码来源:When_finding_records.cs

示例11: Should_throw_exception_if_null_criteria_provided

        public void Should_throw_exception_if_null_criteria_provided()
        {
            using (var context = new RepositoryTestDataContext())
            {
                var repo = new Repository<Order>(context);

                Assert.Throws<ArgumentNullException>(() => repo.Find(null));
            }
        }
开发者ID:NathanGloyn,项目名称:Generic-Repository,代码行数:9,代码来源:When_finding_records.cs

示例12: Simple_Map_Test

 public void Simple_Map_Test()
 {
     UnitOfWork unitOfWork = new UnitOfWork(NHibernateHelper.SessionFactory);
     Repository repo = new Repository(unitOfWork.Session);
     UserProfile userProfile = repo.Find<UserProfile>(m => m.Name.Equals("brunod")).FirstOrDefault();
     Assert.AreEqual("[email protected]", userProfile.Email);
     unitOfWork.Rollback();
     unitOfWork.Dispose();
 }
开发者ID:spc-ofp,项目名称:Vms-Tufman-Recon,代码行数:9,代码来源:UserProfileMapTest.cs

示例13: TestMethod1

        public void TestMethod1()
        {
            var context = new Repository(new AdventureWorksContext(Settings.Default.Connection));


            var query = context.Find<Product>().FilterByColor("Blue");

            Console.WriteLine(((DbQuery<Product>)query).ToString());

        }
开发者ID:DevlinLiles,项目名称:DevlinLiles.Presentations,代码行数:10,代码来源:Queries.cs

示例14: ShouldApplyPaging

        public void ShouldApplyPaging()
        {
            var uri = new Uri("http://localhost/Something/To/Test?$inlinecount=allpages&$skip=1&$top=1");
            var context = GetTestContext();
            var repo = new Repository(context);

            var odataResponse = repo.Find(new GetByOData<ExampleLeaf>(HttpUtility.ParseQueryString(uri.Query)));
            odataResponse.Count.Should().Be(3);
            odataResponse.Results.Should().HaveCount(1);
        }
开发者ID:calebjenkins,项目名称:Highway.Data,代码行数:10,代码来源:BasicODataQueryTests.cs

示例15: GetCostsCount

 public int GetCostsCount(int costCenterId)
 {
     int count;
     using (var context = new SoheilEdmContext())
     {
         var repository = new Repository<Cost>(context);
         count = repository.Find(item=>item.CostCenter != null && item.CostCenter.Id == costCenterId).Count();
     }
     return count;
 }
开发者ID:T1Easyware,项目名称:Soheil,代码行数:10,代码来源:ActualCostReportDataService.cs


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