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


C# DirectSpecification类代码示例

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


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


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