Multiple criteria question

Multiple criteria question

Old forum URL: forums.lhotka.net/forums/t/5900.aspx


albruan posted on Friday, November 28, 2008

I'm finally starting to work with CSLA 3.6 after having used 2.x on my last two projects and have a question about multiple criteria.  Maybe I'm just dense today or something, but how do I go about fetching an item or items from the database based on more than one criteria?  In 2.x, it was easy enough to overload the method for creating the Criteria object based on the Criteria class embedded inside the business object, but I can't quite seem to get my head around doing the same with CSLA 3.6.  It's simple enough to utilize the SingleCriteria class if all I'm interested in is returning an object based on one criteria ... and that handles 80% of my needs ... but how do I go about doing the same if, for instance, I want to return an object based on its ID and whether or not the purchase date falls within a date range?  I've looked at the CredentialsCriteria class in Security and am wondering if something similar is the way to go.

tetranz replied on Friday, November 28, 2008

Nothing has really changed with criteria as far as I know. The SingleCriteria class is simply a convenient ready made object when you only have one criteria. You can still make your own criteria class with as many properties as you like just as you did in earlier versions of CSLA. If the criteria class is defined inside the BO then it needs nothing special at all. If it's defined outside the BO then I think it needs to inherit from CriteriaBase.

JoeFallon1 replied on Saturday, November 29, 2008

tetranz is correct. Nothing has changed in that regard.

I tend to define my criteria outside of the BO so I can re-use them across BOs. But with the new SingleCriteria class I could replace many of mine. (I built them in 1.1 before Generics so there were many of them for a single criteria - 1 for each type - String, Integer, Long, etc.)

Joe

 

Copyright (c) Marimer LLC