I'm getting the error in the subject line thrown on the following code:
public static DataTable RetrieveMyRelationships(Contact contact, string RelationshipType)
{
DataAccessAdapter daa = new DataAccessAdapter(cnString);
ResultsetFields Fields = new ResultsetFields( 8 );
DataTable dt = new DataTable();
IPredicateExpression pe = new PredicateExpression();
IRelationPredicateBucket rpb = new RelationPredicateBucket();
Fields.DefineField(ContactFields.FirstName, 0, "LeftFirstName", "LeftContact");
Fields.DefineField(ContactFields.LastName, 1, "LeftLastName", "LeftContact");
Fields.DefineField(StatusFields.StatusName, 2, "LeftStatusName", "LeftStatus");
Fields.DefineField(ContactRelationshipFields.ContactRelationshipId, 3, "ContactRelationshipID", "ContactRelationship");
rpb.Relations.Add(ContactEntity.Relations.StatusEntityUsingStatusId, "LeftContact", "LeftStatus", JoinHint.Inner);
rpb.Relations.Add(ContactEntity.Relations.ContactRelationshipEntityUsingLeftContactId, "LeftContact", "ContactRelationship", JoinHint.Inner);
Fields.DefineField(ContactFields.FirstName, 4, "RightFirstName", "RightContact");
Fields.DefineField(ContactFields.LastName, 5, "RightLastName", "RightContact");
Fields.DefineField(StatusFields.StatusName, 6, "RightStatusName", "RightStatus");
Fields.DefineField(ContactRelationshipFields.ContactRelationshipId, 7, "ContactRelationshipID_", "ContactRelationship_");
rpb.Relations.Add(ContactEntity.Relations.StatusEntityUsingStatusId, "RightContact", "RightStatus", JoinHint.Inner);
rpb.Relations.Add(ContactEntity.Relations.ContactRelationshipEntityUsingLeftContactId, "RightContact", "ContactRelationship", JoinHint.Inner);
**daa.FetchTypedList(Fields, dt, rpb);**
return dt;
}
The bold, underlined text is the line the error is thrown on. I don't know what the problem could be.
The relationships are:
Status [1]->[m] Contact [1]->[m] ContactRelationship
Inside of ContactRelationship I have:
ContactRelationshipId PK
LeftContactId FK (to Contact table)
RightContactId FK (to Contact table)
ContactRelationshipTypeId FK (to ContactRelationshipType table)
As you can see by the method signature, ultimately I will be accepting as input a Contact and a Relationship Type (the variable types will probably change to better reflect the db later on) and I need to return a list of people who are related to the given Contact and the type of relationship(s) they have.
Thank you for any help you can give.
Wayne E. Pfeffer