Dynamic Typed List Problem

Posts   
 
    
Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 18-Mar-2005 21:54:40   

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?

Posts: 33
Joined: 05-Feb-2005
# Posted on: 19-Mar-2005 05:12:34   

I think there is a constructor for the predicate that allows you to specify an alias. I would try setting it to "Phase".

Jason

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-Mar-2005 11:27:27   

Jason's correct, you've aliased the entities, so you have to specify the alias in the predicate as well.

Frans Bouma | Lead developer LLBLGen Pro
Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 21-Mar-2005 17:33:42   

That worked just fine, thank you guys simple_smile