Starting with version 2.1, sauce now has the ability to specify a query predicate on a data object

    public class TestItemWithPredicate
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public bool IsDeleted { get; set; }

        [QueryPredicate]
        private static IQueryable<TestItemWithPredicate> QueryPredicate(IQueryable<TestItemWithPredicate> query)
        {
            return query.Where(r => r.IsDeleted == false);
        }
    }

You can specify more than one per object, but the important thing is the general method signature. That is..

public static IQueryable<T> $(name)(IQueryable<T> argname)
{

}

This query predicate will automatically be appended by sauce anytime the Query() method is called on an object. This does not apply to the other methods provided by sauce for pulling data out of the database.

Last edited May 30, 2013 at 4:12 AM by iamkrillin, version 4

Comments

No comments yet.