public void AndIsNull_calls_And_with_arguments()
        {
            IClauseCollection <TestClass> clauseCollection = A.Fake <IClauseCollection <TestClass> >();

            IClauseCollectionExtensions.AndIsNull(clauseCollection, x => x.Title);

            A.CallTo(() => clauseCollection.And("Title", SqlOperator.Is, "null")).MustHaveHappened();
        }
        public void And_calls_And_with_arguments()
        {
            IClauseCollection clauseCollection = A.Fake <IClauseCollection>();

            IClauseCollectionExtensions.And(clauseCollection, "foo", 2);

            A.CallTo(() => clauseCollection.And("foo", SqlOperator.Equal, 2)).MustHaveHappened();
        }
Exemple #3
0
        public static IClauseCollection <T> And <T, TProp>(this IClauseCollection <T> clauseCollection, Expression <Func <T, TProp> > property, SqlOperator sqlOperator, TProp value, Func <TProp, bool> applyPredicate)
        {
            if (applyPredicate(value))
            {
                clauseCollection.And(property, sqlOperator, value);
            }

            return(clauseCollection);
        }
Exemple #4
0
        public Select CreateSelect(PropertyQuery query, bool getCount = false)
        {
            Select <DataModel.VProperty> select = _modelDataProvider.NewSelect();

            IClauseCollection <DataModel.VProperty> where = select
                                                            .Where(x => x.Type, (byte)query.ListingType)
                                                            .And(x => x.PropertyType, query.PropertyType, x => x != PropertyType.All)
                                                            .And(x => x.BedroomCount, SqlOperator.GreaterThanOrEqual, query.MinBedrooms, x => x.HasValue)
                                                            .And(x => x.BedroomCount, SqlOperator.LessThanOrEqual, query.MaxBedrooms, x => x.HasValue)
                                                            .And(x => x.Cost, SqlOperator.GreaterThanOrEqual, query.MinCost, x => x.HasValue)
                                                            .And(x => x.Cost, SqlOperator.LessThanOrEqual, query.MaxCost, x => x.HasValue)
                                                            .And(x => x.PostCode, SqlOperator.Like, query.PostCode, x => !string.IsNullOrEmpty(x))
                                                            .And(x => x.IsCommercial, query.IsCommercial, x => x.GetValueOrDefault(false));


            if (!query.Status.HasFlag(PropertyStatus.Archived))
            {
                where.And(x => x.Status, SqlOperator.NotEqual, PropertyStatus.Archived);
            }

            where.And(x => x.Status, PropertyStatus.Available, x => query.ExcludeUnavailable);

            if (!string.IsNullOrEmpty(query.Keywords))
            {
                where.And()
                .Or(x => x.Address01, SqlOperator.Like, query.Keywords)
                .Or(x => x.Address02, SqlOperator.Like, query.Keywords)
                .Or(x => x.PostCode, SqlOperator.Like, query.Keywords)
                .Or(x => x.Title, SqlOperator.Like, query.Keywords);
            }

            select.IncludeCount(getCount);
            select.Paging(query.Page, query.MaxPerPage);

            return(select);
        }
Exemple #5
0
 public static IClauseCollection And(this IClauseCollection clauseCollection, string column, object value)
 {
     return(clauseCollection.And(column, SqlOperator.Equal, value));
 }
Exemple #6
0
 public static IClauseCollection <T> AndIsNull <T, TProp>(this IClauseCollection <T> clauseCollection, Expression <Func <T, TProp> > property)
 {
     clauseCollection.And(property.MemberName(), SqlOperator.Is, "null");
     return(clauseCollection);
 }
Exemple #7
0
 public static IClauseCollection <T> And <T, TProp>(this IClauseCollection <T> clauseCollection, Expression <Func <T, TProp> > property, TProp value)
 {
     return(clauseCollection.And(property, SqlOperator.Equal, value));
 }