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


C# IRepository.Find方法代码示例

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


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

示例1: Find_Should_Return_First_Ordered_Item_Which_Satisfies_Specification_WIth_Sorting_Predicate

        public void Find_Should_Return_First_Ordered_Item_Which_Satisfies_Specification_WIth_Sorting_Predicate(IRepository<Contact, string> repository)
        {
            for (var i = 1; i <= 3; i++)
            {
                var contact = new Contact { Name = "Test User " + i };
                repository.Add(contact);
            }

            var result = repository.Find(new Specification<Contact>(p => p.Name.StartsWith("Test")), new SortingOptions<Contact, string>(c => c.Name, true));
            result.Name.ShouldEqual("Test User 3");

            var result2 = repository.Find(new Specification<Contact>(p => p.Name.StartsWith("Test")), new SortingOptions<Contact, string>(c => c.Name, false));
            result2.Name.ShouldEqual("Test User 1");
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:14,代码来源:RepositoryFindTests.cs

示例2: Main

        static void Main(string[] args)
        {
            IoC.Register();
            _repo = IoC.Resolve<IRepository>();

            var geos = _repo.Find<City>().ToList();
            Console.WriteLine(string.Format("{0} total cities...", geos.Count()));

            int i =0;
            foreach (var geo in geos)
            {
                if (geo.Geography.GetType() == typeof(NetTopologySuite.Geometries.MultiPoint))
                {
                    Console.WriteLine(string.Format("{0} is a MultiPoint...", geo.Name));
                    var point = new NetTopologySuite.Geometries.Point(geo.Geography.Coordinates.First());
                    geo.Geography = point;
                    _repo.Save<City>(geo);
                    _repo.SubmitChanges();
                    Console.WriteLine(string.Format("{0} updated to Point...", geo.Name));
                    i++;
                }
            }
            Console.WriteLine(string.Format("{0} total Cities updated...", i));
            Console.Read();
        }
开发者ID:robbygregory,项目名称:GeospatialIntro,代码行数:25,代码来源:Program.cs

示例3: Setup

        public void Setup()
        {
            context = new InMemoryDataContext();
            repo = new Repository(context);

            // All tests will fail if the Create does not work
            repo.Context.Add(new Customer
            {
                FirstName = "Kevin",
                LastName = "Berry",
                Company = new Company("Improving Enterprises"),
                Email = "[email protected]",
                Phone = "(555)123-4567"
            });
            repo.Context.Commit();

            customerK = repo.Find(new FindCustomerByFirstName("Kevin")).First();
        }
开发者ID:KevinEdwardBerry,项目名称:Customers,代码行数:18,代码来源:CRUD_Tests.cs

示例4: ValidateUser

        public static Guid? ValidateUser(IRepository repository, string username, string password)
        {
            var user = repository.Find<User>(x => x.Username == username).SingleOrDefault();

            if (user == null)
            {
                return null;
            }

            if (user.VerifyPassword(password))
            {
                return new Guid(user.Guid);
            }
            else
            {
                return null;
            }
        }
开发者ID:nfink,项目名称:Haven,代码行数:18,代码来源:UserMapper.cs

示例5: GetByFeatureID

        //Methods
        public List<BLL.BusinessObjects.Attribute> GetByFeatureID(int FeatureID)
        {
            //
            List<BLL.BusinessObjects.Attribute> BLLAttributes;
            using (_AttributeRepository = new GenericRepository<DAL.DataEntities.Attribute>())
            {
                IEnumerable<DAL.DataEntities.Attribute> DALAttributes = _AttributeRepository.Find(m => m.FeatureID == FeatureID);

                //Create Business objects for each DAL object
                BLLAttributes = new List<BusinessObjects.Attribute>();
                foreach (DAL.DataEntities.Attribute DALAttribute in DALAttributes)
                {
                    //Create the BLL object
                    BLL.BusinessObjects.Attribute BLLAttribute = BLL.BusinessObjects.Attribute.CreateInstance(DALAttribute);
                    BLLAttributes.Add(BLLAttribute);
                }
            }
            return BLLAttributes;
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:20,代码来源:AttributeService.cs

示例6: GetByModelID

        public List<BLL.BusinessObjects.CustomRule> GetByModelID(int ModelID)
        {
            //
            List<BLL.BusinessObjects.CustomRule> BCustomRules;
            using (_CustomRuleRepository = new GenericRepository<DAL.DataEntities.CustomRule>())
            {
                IEnumerable<DAL.DataEntities.CustomRule> customRules = _CustomRuleRepository.Find(m => m.ModelID == ModelID);

                //Create Business objects for each DAL object
                BCustomRules = new List<BusinessObjects.CustomRule>();
                foreach (DAL.DataEntities.CustomRule customRule in customRules)
                {
                    BCustomRules.Add((BLL.BusinessObjects.CustomRule)BLL.BusinessObjects.CustomRule.CreateInstance(customRule));
                }
            }
            return BCustomRules;
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:17,代码来源:CustomRuleService.cs

示例7: GetByModelID

        public List<BLL.BusinessObjects.Relation> GetByModelID(int ModelID)
        {
            //
            List<BLL.BusinessObjects.Relation> BRelations;
            using (_RelationRepository = new GenericRepository<DAL.DataEntities.Relation>())
            {
                IEnumerable<DAL.DataEntities.Relation> relations = _RelationRepository.Find(m =>
                    m.ModelID == ModelID);

                //Create Business objects for each DAL object
                BRelations = new List<BusinessObjects.Relation>();
                foreach (DAL.DataEntities.Relation relation in relations)
                {
                    BRelations.Add((BLL.BusinessObjects.Relation)BLL.BusinessObjects.Relation.CreateInstance(relation));
                }
            }
            return BRelations;
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:18,代码来源:RelationService.cs

示例8: GetByUserID

        public List<BLL.BusinessObjects.UITemplate> GetByUserID(int userid, bool excludeContentAndCSS = false)
        {
            //
            List<BLL.BusinessObjects.UITemplate> BUITemplates;
            using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
            {
                List<DAL.DataEntities.UITemplate> templates = _UITemplateRepository.Find(m => m.UserID == userid).ToList<DAL.DataEntities.UITemplate>();

                //Create Business objects for each DAL object
                BUITemplates = new List<BusinessObjects.UITemplate>();
                foreach (DAL.DataEntities.UITemplate template in templates)
                {
                    if (excludeContentAndCSS)
                    {
                        template.Content = "";
                        template.Stylesheet = "";
                    }

                    BUITemplates.Add((BLL.BusinessObjects.UITemplate)BLL.BusinessObjects.UITemplate.CreateInstance(template));
                }
            }
            return BUITemplates;
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:23,代码来源:UITemplateService.cs

示例9: GetByUserID

        public List<BLL.BusinessObjects.Model> GetByUserID(int userid)
        {
            //
            List<BLL.BusinessObjects.Model> BModels;
            using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
            {
                List<DAL.DataEntities.Model> models = _ModelRepository.Find(m => m.UserID == userid).ToList<DAL.DataEntities.Model>();

                //Create Business objects for each DAL object
                BModels = new List<BusinessObjects.Model>();
                foreach (DAL.DataEntities.Model model in models)
                {
                    BModels.Add((BLL.BusinessObjects.Model)BLL.BusinessObjects.Model.CreateInstance(model));
                }
            }
            return BModels;
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:17,代码来源:ModelService.cs

示例10: Find_Should_Return_Single_Item_Which_Satisfies_Predicate

        public void Find_Should_Return_Single_Item_Which_Satisfies_Predicate(IRepository<Contact, string> repository)
        {
            for (var i = 1; i <= 3; i++)
            {
                var contact = new Contact { Name = "Test User " + i };
                repository.Add(contact);
            }

            var result = repository.Find(p => p.Name == "Test User 1");
            result.Name.ShouldEqual("Test User 1");
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:11,代码来源:RepositoryFindTests.cs

示例11: Delete

        public void Delete(int id)
        {
            DAL.DataEntities.Feature feature;
            using (_FeatureRepository = new GenericRepository<DAL.DataEntities.Feature>())
            {
                feature = _FeatureRepository.SingleOrDefault(m => m.ID == id);

                //Cascade delete on all related FeatureSelections
                using (_FeatureSelectionRepository = new GenericRepository<DAL.DataEntities.FeatureSelection>())
                {
                    IEnumerable<DAL.DataEntities.FeatureSelection> featureSelections = _FeatureSelectionRepository.Find(k => k.FeatureID == feature.ID);
                    foreach (DAL.DataEntities.FeatureSelection featureSelection in featureSelections)
                    {
                        _FeatureSelectionRepository.Delete(featureSelection);
                    }

                    _FeatureSelectionRepository.SaveChanges();
                }

                //
                _FeatureRepository.Delete(feature);
                _FeatureRepository.SaveChanges();
            }
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:24,代码来源:FeatureService.cs

示例12: GetByModelID

        public List<BLL.BusinessObjects.Feature> GetByModelID(int ModelID)
        {
            //
            List<BLL.BusinessObjects.Feature> BFeatures;
            using (_FeatureRepository = new GenericRepository<DAL.DataEntities.Feature>())
            {
                IEnumerable<DAL.DataEntities.Feature> DALfeatures = _FeatureRepository.Find(m => m.ModelID == ModelID);

                //Create Business objects for each DAL object
                BFeatures = new List<BusinessObjects.Feature>();
                foreach (DAL.DataEntities.Feature DALfeature in DALfeatures)
                {
                    //Create the BLL feature
                    BLL.BusinessObjects.Feature BLLfeature = BLL.BusinessObjects.Feature.CreateInstance(DALfeature);

                    BFeatures.Add(BLLfeature);
                }
            }
            return BFeatures;
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:20,代码来源:FeatureService.cs

示例13: FindUserByEmailAsync

 private static async Task<bool> FindUserByEmailAsync(IRepository<User> usersColl, string email)
 {
     var foundUser = await usersColl.Find(u => u.Email == email).FirstOrDefaultAsync();
     return (null != foundUser);
 }
开发者ID:alexestevam,项目名称:UsersVoice,代码行数:5,代码来源:Program.cs

示例14: GetByModelID

 public List<BLL.BusinessObjects.Configuration> GetByModelID(int modelID)
 {
     //
     List<BLL.BusinessObjects.Configuration> BLLConfigurations = new List<BusinessObjects.Configuration>();
     using (_ConfigurationRepository = new GenericRepository<DAL.DataEntities.Configuration>())
     {
         List<DAL.DataEntities.Configuration> DALConfigurations = _ConfigurationRepository.Find(m => m.ModelID == modelID).ToList<DAL.DataEntities.Configuration>();
         DALConfigurations.ForEach(DALentity => BLLConfigurations.Add(BLL.BusinessObjects.Configuration.CreateInstance(DALentity)));
     }
     return BLLConfigurations;
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:11,代码来源:ConfigurationService.cs

示例15: GetByModelID

        public List<BLL.BusinessObjects.Constraint> GetByModelID(int ModelID)
        {
            //
            List<BLL.BusinessObjects.Constraint> BConstraints;
            using (_ConstraintRepository = new GenericRepository<DAL.DataEntities.Constraint>())
            {
                IEnumerable<DAL.DataEntities.Constraint> customRules = _ConstraintRepository.Find(m => m.ModelID == ModelID);

                //Create Business objects for each DAL object
                BConstraints = new List<BusinessObjects.Constraint>();
                foreach (DAL.DataEntities.Constraint customRule in customRules)
                {
                    BConstraints.Add((BLL.BusinessObjects.Constraint)BLL.BusinessObjects.Constraint.FromDataEntity(customRule));
                }
            }
            return BConstraints;
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:17,代码来源:ConstraintService.cs


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