If you want to use datedif to filter on a date, you can use code like:

        public EntityCollection<Customers> GetCustomers(DateTime creationDate)
        {
            EntityCollection<AfhaalopdrachtEntity> result = new EntityCollection<AfhaalopdrachtEntity>();

            // Filter
            IRelationPredicateBucket filter = new RelationPredicateBucket();

            IPredicate customerCreateDateFilter = new EntityField2("CreateCustomerDiff", new DbFunctionCall("DATEDIFF(day, {0}, {1})", new object[] { CustomerFields.CreationDate, creationDate})) == 0;
            filter.PredicateExpression.Add(customerCreateDateFilter );

            // Fetch (get the data)
            using (DataAccessAdapter da = ConnectionHelper.GetAdapter(Source.Pegaso, Global.Logger))
            {
                da.FetchEntityCollection(result, filter);
            }

           return result;
        }

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.