I decided to use v4 for a project and am curious if there's any advantage in using a custom criteria object to pass multiple values in the DataPortal.Fetch method as opposed to passing them as a param array?
No, if you are passing a single, serializable/primitive value then there's no value in having your own criteria class.
Rocky, thanks for csla, writing a great book, and supporting us newbies on your forums. I really appreciate it.
I was under the impression that for CSLA.NET 4 a Criteria class was no longer needed. Re-reading "CSLA 4 data portal changes" on your blog you say "It is now possible to use any serializable object as a criteria."
[pedantic mode on]
When you say "a criteria" it looks like you mean "one criteria". But then again "criteria" is plural so one should say "one criterion" or "a criterion".
[pedantic mode off]
Entering the no jokes mode, the point is: when do we need to use a Criteria class?
a) when we need to pass a non primitive type?
b) when we need to pass more than one type?
That is correct, you need a criteria class when
I thought about extending the data portal calls to accept params arrays, like I do with the child data portal. But there are problems with using params that many people have encountered with the child data portal, and I don't know how to solve them. The problems are edge cases, but they do occur, and I decided I didn't want to introduce that issue to the top-level data portal without a solution.
So you can pass any one serializable or primitive value as criteria in CSLA 4. Of course your serializable value can be a custom criteria (or any other business type), so the flexibility is very high.
Picking up on this thread and hope you could clarify one thing.
You say that you need a criteria class when: "1. You need to pass a non-primitive type". Is that true for strings as well, since strings are not a primitive type.
String work just fine - no need for a criteria object when the criteria is one string value..
"you need to pass a non-primitive and otherwise non-serializable type"
For CSLA 4.x you should regard SingleCriteria as obsolete - you normally only need a criteria object when
Copyright (c) Marimer LLC