Hmmm....maybe it's me, or maybe it's not, but I have tried to use the code from the other thread you mentioned and I saw this code:
IEntityField2 setField = EntityFieldFactory.Create(BlockVersionFieldIndex.Version);
setField.AggregateFunctionToApply = AggregateFunction.Max;
setField.ObjectAlias = "VC";
// bucket is not necessary here,
//RelationPredicateBucket setFilter = new RelationPredicateBucket();
IPredicate setFilter = PredicateFactory.CompareValue(BlockVersionFieldIndex.Name, ComparisonOperator.Equal, @"""GIS"".""BLOCK_VERSION"".""NAME""", "BV", "VC");
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(new FieldCompareSetPredicate(
EntityFieldFactory.Create(BlockVersionFieldIndex.Version), null,
setField, null,
SetOperator.Equal,
new PredicateExpression(setFilter),
null,
string.Empty,
0,
null,
false,
null));
EntityCollection blocks = new EntityCollection(new BlockVersionEntityFactory());
mAdapter.FetchEntityCollection(blocks, filter, 0);
Ok...I use SelfServicing, but I thought I could change it to that, however:
This line of code the IDE doesn't like, it says:
Cannot implicitly convert type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField' to 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField2'
IEntityField2 setField = EntityFieldFactory.Create(BlockVersionFieldIndex.Version);
So I thought...ok, then I'll change the IEntitityField2 to IEntityField and check out what happens then, but then I have a problem with this line:
IPredicate setFilter = PredicateFactory.CompareValue(BlockVersionFieldIndex.Name, ComparisonOperator.Equal, @"""GIS"".""BLOCK_VERSION"".""NAME""", "BV", "VC");
I can't add this last "VC" since this is bool negate, so I can't do that either.
Then at last, when I changed the "VC" into false, and run the code I get a null reference exception at the getMulti of my collection....
So now I have really no idea what to do now ...
Here is my Code I tried:
MyTableCollection mrc = new MyTableCollection();
PredicateExpression filter = new PredicateExpression();
filter.Add(PredicateFactory.CompareValue(MyTableFieldIndex.ObjNo, ComparisonOperator.Equal, pt.MachineObjNo));
IEntityField2 setField = EntityFieldFactory.Create(MyTableFieldIndex.ReadingDate);
setField.AggregateFunctionToApply = AggregateFunction.Max;
setField.ObjectAlias = "MR2";
IPredicate setFilter = PredicateFactory.CompareValue(MyTableFieldIndex.ReadingDate, ComparisonOperator.Equal, @"DBO.MY_TABLE.READING_DATE" , "MR2", false);
filter.Add(new FieldCompareSetPredicate(EntityFieldFactory.Create(MyTableFieldIndex.ReadingDate), null, setField, null, SetOperator.Equal, new PredicateExpression(setFilter), null, "MR1", 0, null, false, null));
mrc.GetMulti(filter, 0);
Please help me...
G.I.