Walla: correct, I just copied what was above without thinking
Otis: I tried this earlier today and yeah, it won't work for the Predicate -> PredicateExpression conversion because PredicateExpression derives from Predicate and C# doesn't allow you to define an operator (implicit or explicit) that converts from a base class or interface.
However, you can do this for a Predicate -> RelationPredicateBucket like so:
public static implicit operator RelationPredicateBucket(Predicate predicate)
{
RelationPredicateBucket bucket = new RelationPredicateBucket(predicate);
return bucket;
}
// works
RelationPredicateBucket bucket = CarFields.Initials == "CSXT";
a.FetchEntityCollection(c, bucket);
// works
a.FetchEntityCollection(c, (RelationPredicateBucket) (CarFields.Initials == "CSXT"));
// doesn't work, can't implicitly cast
a.FetchEntityCollection(c, CarFields.Initials == "CSXT");
Now, is that the correct thing to do anyway? Pulling back a little, I'm wondering if it is abuse of the language features. It doesn't seem so for the Predicate -> PredicateExpression conversion, to me, but it does seem a little dirty for the Predicate -> RelationPrediacteBucket.
Anyway, it's very easy to just do this anyway:
a.FetchEntityCollection(c, new RelationPredicateBucket(CarFields.Initials == "CSXT"));
Waiting for LINQ ...