I am creating a typed list on the fly with the following code
ResultsetFields fields = new ResultsetFields(13);
fields.DefineField(PhaseFieldIndex.ID, 0, "ID", "Phase");
fields.DefineField(PhaseFieldIndex.UserID, 1, "UserID", "Phase");
fields.DefineField(PhaseFieldIndex.ParentID, 2, "ParentID", "Phase");
fields.DefineField(PhaseFieldIndex.Name, 3, "Name", "Phase");
fields.DefineField(PhaseFieldIndex.EndDate, 4, "EndDate", "Phase");
fields.DefineField(PhaseFieldIndex.CompletionDate, 5, "CompletionDate", "Phase");
fields.DefineField(PhaseFieldIndex.Duration, 6, "Duration", "Phase");
fields.DefineField(PhaseFieldIndex.DurationUnitID, 7, "DurationUnitID", "Phase");
fields.DefineField(PhaseFieldIndex.Sequence, 8, "Sequence", "Phase");
fields.DefineField(PhaseFieldIndex.ProjectID, 9, "ProjectID", "Phase");
fields.DefineField(PhaseFieldIndex.StatusID, 10, "StatusID", "Phase");
fields.DefineField(LookUpFieldIndex.Description, 11, "StatusDescription", "LookUp");
fields.DefineField(LookUpFieldIndex.Value, 12, "UnitValue", "LookUp1");
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.Relations.Add(PhaseEntity.Relations.LookUpEntityUsingStatusID, "Phase", "LookUp", JoinHint.Left);
bucket.Relations.Add(PhaseEntity.Relations.LookUpEntityUsingDurationUnitID, "Phase", "LookUp1", JoinHint.Left);
DataTable dt = new DataTable();
using ( DataAccessAdapter adapter = new DataAccessAdapter() ) {
adapter.FetchTypedList(fields, dt, bucket, 0, null, true, null, pageNumber, pageSize);
}
return dt;
And this works just fine. However when I try to add a predicate expression
//bucket.PredicateExpression.Add( PredicateFactory.CompareValue( PhaseFieldIndex.ProjectID, ComparisonOperator.Equal, projectID ) );
I get an error
The column prefix 'PTS.dbo.Phase' does not match with a table name or alias name used in the query.
So what am I doing wrong?