• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DirectSpecification类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DirectSpecification的典型用法代码示例。如果您正苦于以下问题:C# DirectSpecification类的具体用法?C# DirectSpecification怎么用?C# DirectSpecification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DirectSpecification类属于命名空间,在下文中一共展示了DirectSpecification类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ByAddress

        public static ISpecification<Place> ByAddress(Address address)
        {
            Specification<Place> specification = new TrueSpecification<Place>();

            if (address != null)
            {
                var stspec = new DirectSpecification<Place>(
                    p => p.Address.Street.ToLower().Contains(
                        address.Street.ToLower()
                        )
                    );

                var dtspec = new DirectSpecification<Place>(
                    p => p.Address.District.ToLower().Contains(
                        address.District.ToLower()
                        )
                    );
                var zpspec = new DirectSpecification<Place>(
                    p => p.Address.ZipCode == address.ZipCode
                    );

                specification &= stspec || dtspec || zpspec;
            }

            return specification;
        }
开发者ID:experienciacessivel,项目名称:experienciacessivel,代码行数:26,代码来源:PlaceSpecifications.cs


示例2: CreateAndSpecificationTest

        public void CreateAndSpecificationTest()
        {
            //Arrange
            DirectSpecification<SampleEntity> leftAdHocSpecification;
            DirectSpecification<SampleEntity> rightAdHocSpecification;

            var identifier = Guid.NewGuid();
            Expression<Func<SampleEntity, bool>> leftSpec = s => s.Id == identifier;
            Expression<Func<SampleEntity, bool>> rightSpec = s => s.SampleProperty.Length > 2;

            leftAdHocSpecification = new DirectSpecification<SampleEntity>(leftSpec);
            rightAdHocSpecification = new DirectSpecification<SampleEntity>(rightSpec);

            //Act
            AndSpecification<SampleEntity> composite = new AndSpecification<SampleEntity>(leftAdHocSpecification, rightAdHocSpecification);

            //Assert
            Assert.IsNotNull(composite.SatisfiedBy());
            Assert.ReferenceEquals(leftAdHocSpecification, composite.LeftSideSpecification);
            Assert.ReferenceEquals(rightAdHocSpecification, composite.RightSideSpecification);

            var list = new List<SampleEntity>();
            var sampleA = new SampleEntity() {  SampleProperty = "1" };
            sampleA.ChangeCurrentIdentity(identifier);

            var sampleB = new SampleEntity() { SampleProperty = "the sample property" };
            sampleB.ChangeCurrentIdentity(identifier);

            list.AddRange(new SampleEntity[] { sampleA, sampleB });
            

            var result = list.AsQueryable().Where(composite.SatisfiedBy()).ToList();

            Assert.IsTrue(result.Count == 1);
        }
开发者ID:ljvblfz,项目名称:MicrosoftNLayerApp,代码行数:35,代码来源:SpecificationTests.cs


示例3: CreateNotSpecificationFromNegationOperator

        public void CreateNotSpecificationFromNegationOperator()
        {
            var spec = new DirectSpecification<SampleEntity>(s=>s.Name==EntityName);

            ISpecification<SampleEntity> notSpec = !spec;

            Assert.IsNotNull(notSpec);
        }
开发者ID:gitter-badger,项目名称:Hangerd,代码行数:8,代码来源:SpecificationTest.cs


示例4: MyAdList

 public ActionResult MyAdList()
 {
     int userId= WebSecurity.GetUserId(User.Identity.Name);
     ISpecification<Advertisement> myAdSpec = new DirectSpecification<Advertisement>(ad => ad.OwnerID == userId );
     var lst = productRepository.GetAdvertisementsList(myAdSpec);
     ViewBag.IsEditable = true;
     return View("AdList",lst);
 }
开发者ID:neda-rezaei,项目名称:OziBazaar,代码行数:8,代码来源:AdController.cs


示例5: DirectSpecification_Constructor_NullSpecThrowArgumentNullException_Test

        public void DirectSpecification_Constructor_NullSpecThrowArgumentNullException_Test()
        {
            //Arrange
            DirectSpecification<TEntity> adHocSpecification;
            Expression<Func<TEntity, bool>> spec = null;

            //Act
            adHocSpecification = new DirectSpecification<TEntity>(spec);
        }
开发者ID:alejsherion,项目名称:gggets,代码行数:9,代码来源:SpecificationsTests.cs


示例6: CreateDirectSpecificationNullSpecThrowArgumentNullExceptionTest

        public void CreateDirectSpecificationNullSpecThrowArgumentNullExceptionTest()
        {
            //Arrange
            DirectSpecification<SampleEntity> adHocSpecification;
            Expression<Func<SampleEntity, bool>> spec = null;

            //Act
            adHocSpecification = new DirectSpecification<SampleEntity>(spec);
        }
开发者ID:ljvblfz,项目名称:MicrosoftNLayerApp,代码行数:9,代码来源:SpecificationTests.cs


示例7: ConsultaCategoriaProduto

        public static Specification<CategoriaProduto> ConsultaCategoriaProduto(string texto)
        {
            Specification<CategoriaProduto> spec = new DirectSpecification<CategoriaProduto>(c => true);

            if (!string.IsNullOrEmpty(texto))
            {
                spec = new DirectSpecification<CategoriaProduto>(c => c.Nome.Contains(texto));
            }

            return spec;
        }
开发者ID:MURYLO,项目名称:pegazuserp,代码行数:11,代码来源:ProdutoSpecifications.cs


示例8: ConsultaEmail

        public static Specification<Usuario> ConsultaEmail(string email)
        {
            if (email != null)
            {
                email = email.Trim();
            }

            Specification<Usuario> spec = new DirectSpecification<Usuario>(c => true);

            return spec;
        }
开发者ID:MURYLO,项目名称:pegazuserp,代码行数:11,代码来源:UsuarioSpecification.cs


示例9: ConsultaTexto

        public static Specification<Usuario> ConsultaTexto(string texto)
        {
            Specification<Usuario> spec = new DirectSpecification<Usuario>(c => true);

            if (!string.IsNullOrWhiteSpace(texto))
            {
                spec &= new DirectSpecification<Usuario>(c => c.NomeUsuario.ToUpper().Contains(texto.ToUpper()));
            }

            return spec;
        }
开发者ID:MURYLO,项目名称:pegazuserp,代码行数:11,代码来源:UsuarioSpecification.cs


示例10: CriaAndSpecificationComLambdaRightNullEThrowArgumentNullExceptionTest

        public void CriaAndSpecificationComLambdaRightNullEThrowArgumentNullExceptionTest()
        {
            //Arrange
            CompositeSpecification<ClienteStub> compoSpecification;
            Expression<Func<ClienteStub, bool>> lambda = s => s.Nome != string.Empty;

            DirectSpecification<ClienteStub> direct = new DirectSpecification<ClienteStub>(lambda);

            //Act
            compoSpecification = new AndSpecification<ClienteStub>(direct, null);
        }
开发者ID:rodrigolessa,项目名称:zimmer,代码行数:11,代码来源:SpecificationTest.cs


示例11: OrderFromDateRange

        /// <summary>
        /// The orders in a date range
        /// </summary>
        /// <param name="startDate">The start date </param>
        /// <param name="endDate">The end date</param>
        /// <returns>Related specification for this criteria</returns>
        public static ISpecification<Order> OrderFromDateRange(DateTime? startDate, DateTime? endDate)
        {
            Specification<Order> spec = new TrueSpecification<Order>();

            if (startDate.HasValue)
                spec &= new DirectSpecification<Order>(o => o.OrderDate > (startDate ?? DateTime.MinValue));

            if (endDate.HasValue)
                spec &= new DirectSpecification<Order>(o => o.OrderDate < (endDate ?? DateTime.MaxValue));

            return spec;
        }
开发者ID:ljvblfz,项目名称:MicrosoftNLayerApp,代码行数:18,代码来源:OrdersSpecifications.cs


示例12: CreateNewDirectSpecificationTest

        public void CreateNewDirectSpecificationTest()
        {
            //Arrange
            DirectSpecification<SampleEntity> adHocSpecification;
            Expression<Func<SampleEntity, bool>> spec = s => s.Id == Guid.NewGuid();

            //Act
            adHocSpecification = new DirectSpecification<SampleEntity>(spec);

            //Assert
            Assert.ReferenceEquals(new PrivateObject(adHocSpecification).GetField("_MatchingCriteria"), spec);
        }
开发者ID:ljvblfz,项目名称:MicrosoftNLayerApp,代码行数:12,代码来源:SpecificationTests.cs


示例13: DirectSpecification_Constructor_Test

        public void DirectSpecification_Constructor_Test()
        {
            //Arrange
            DirectSpecification<TEntity> adHocSpecification;
            Expression<Func<TEntity,bool>> spec = s => s.Id==0;

            //Act
            adHocSpecification = new DirectSpecification<TEntity>(spec);

            //Assert
            Assert.ReferenceEquals(new PrivateObject(adHocSpecification).GetField("_MatchingCriteria"), spec);
        }
开发者ID:alejsherion,项目名称:gggets,代码行数:12,代码来源:SpecificationsTests.cs


示例14: BankAccountIbanNumber

      /// <summary>
      ///    Specification for bank accounts with number like to <paramref name="ibanNumber" />
      /// </summary>
      /// <param name="ibanNumber">The bank account number</param>
      /// <returns>Associated specification</returns>
      public static ISpecification<BankAccount> BankAccountIbanNumber(string ibanNumber)
      {
         Specification<BankAccount> specification = new TrueSpecification<BankAccount>();

         if (!String.IsNullOrWhiteSpace(ibanNumber))
         {
            specification &= new DirectSpecification<BankAccount>(
               (b) => b.Iban.ToLower().Contains(ibanNumber.ToLower()));
         }

         return specification;
      }
开发者ID:MyLobin,项目名称:NLayerAppV2,代码行数:17,代码来源:BankAccountSpecifications.cs


示例15: Sepcification_OfType_Test

        public void Sepcification_OfType_Test()
        {
            //初始化
            var baseSpec = new DirectSpecification<BaseEntity>(be => be.Id == 1);

            //操作
            var inheritSpec = baseSpec.OfType<InheritEntity>();

            //验证
            Assert.IsNotNull(inheritSpec);
            Assert.IsTrue(inheritSpec.SatisfiedBy().Compile()(new InheritEntity() { Id = 1 }));
        }
开发者ID:KevinDai,项目名称:Framework.Infrastructure,代码行数:12,代码来源:SpecificationTest.cs


示例16: ByName

        public static ISpecification<Place> ByName(string name)
        {
            Specification<Place> specification = new TrueSpecification<Place>();

            if (!string.IsNullOrWhiteSpace(name))
            {
                specification &= new DirectSpecification<Place>(
                    p => p.Name.ToLower().Contains(name.ToLower())
                    );
            }

            return specification;
        }
开发者ID:experienciacessivel,项目名称:experienciacessivel,代码行数:13,代码来源:PlaceSpecifications.cs


示例17: UserName

        /// <summary>
        /// Specification for menu with application code like to <paramref name="text"/>
        /// </summary>
        /// <param name="text">The text to search</param>
        /// <returns>Associated specification for this criterion</returns>
        public static ISpecification<User> UserName(string userName)
        {
            Specification<User> specification = new TrueSpecification<User>();

            if (!string.IsNullOrWhiteSpace(userName))
            {
                var nameSpecification = new DirectSpecification<User>(c => c.UserName.ToLower() == userName.ToLower());

                specification &= nameSpecification;
            }

            return specification;
        }
开发者ID:rodmjay,项目名称:Trul,代码行数:18,代码来源:UserSpecifications.cs


示例18: DirectSpecification_Constructor_Test

        public void DirectSpecification_Constructor_Test()
        {
            //Arrange
            DirectSpecification<Entity> adHocSpecification;
            Expression<Func<Entity,bool>> spec = s => s.Id==0;

            //Act
            adHocSpecification = new DirectSpecification<Entity>(spec);

            //Assert
            var expectedValue = adHocSpecification.GetType().GetField("_MatchingCriteria", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(adHocSpecification);
            Assert.AreSame(expectedValue, spec);
        }
开发者ID:rretamal,项目名称:Hexa.Core,代码行数:13,代码来源:Specifications.cs


示例19: CheckNotSpecificationOperators

        public void CheckNotSpecificationOperators()
        {
            var spec = new DirectSpecification<SampleEntity>(s=>s.Name==EntityName);

            var notSpec = !spec;

            ISpecification<SampleEntity> resultAnd = notSpec && spec;
            ISpecification<SampleEntity> resultOr = notSpec || spec;

            Assert.IsNotNull(notSpec);
            Assert.IsNotNull(resultAnd);
            Assert.IsNotNull(resultOr);
        }
开发者ID:gitter-badger,项目名称:Hangerd,代码行数:13,代码来源:SpecificationTest.cs


示例20: ApplicationCodeFullText

        /// <summary>
        /// Specification for menu with application code like to <paramref name="text"/>
        /// </summary>
        /// <param name="text">The text to search</param>
        /// <returns>Associated specification for this criterion</returns>
        public static ISpecification<Menu> ApplicationCodeFullText(string text)
        {
            Specification<Menu> specification = new TrueSpecification<Menu>();

            if(!String.IsNullOrWhiteSpace(text)) {
                var nameSpecification = new DirectSpecification<Menu>(c => c.ApplicationCode.ToLower().Contains(text));

                specification &= nameSpecification;

            }

            return specification;
        }
开发者ID:rodmjay,项目名称:Trul,代码行数:18,代码来源:MenuSpecifications.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Direction类代码示例发布时间:2022-05-24
下一篇:
C# Dir类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap