Multi Entity Filtering

Posts   
 
    
Hameed
User
Posts: 34
Joined: 02-May-2005
# Posted on: 25-Jul-2005 13:16:43   

Hi All,

I have tables, PatientMedicalStaff, MedicalStaff and TypeValue.

PatientMedicalStaff has a FK of MedicalStaff (FK_MEdicalStaffID) and MedicalStaff has a FK of TypeValue (FK_TypeValueID)

now what I want to do is get all records in PatientMedicalStaff (for partiular Patient) where TypeValue is equal to Consultant.

I am guessing this can be done by RelationsCollections but I cannot figure it out.

I have created the following code. where restrictions is an array of string.


            RelationCollection relationsToUse = null;
            IPredicateExpression filter = new PredicateExpression();
                    
            if(restrictions != null)
            {
                relationsToUse = new RelationCollection();
                relationsToUse.Add(MedicalStaffEntity.Relations.PatientMedicalStaffEntityUsingFK_MedicalStaff);                 
                relationsToUse.Add(TypeValueEntity.Relations.MedicalStaffEntityUsingFK_MedicalStaffType);
                
                filter.Add(PredicateFactory.CompareValue(PMS.DAL.PatientMedicalStaffFieldIndex.IsDeleted, ComparisonOperator.Equal,false));
                filter.AddWithAnd(PredicateFactory.CompareValue(PMS.DAL.PatientMedicalStaffFieldIndex.FK_PatientID, ComparisonOperator.Equal,Manager.CurrentPatient.Patient_ID));
                filter.AddWithAnd(PredicateFactory.CompareValue(PMS.DAL.TypeValueFieldIndex.TypeName, ComparisonOperator.Equal,"MEDICALSTAFF"));
                filter.AddWithOr(PredicateFactory.CompareRange(PMS.DAL.TypeValueFieldIndex.DisplayValue,restrictions));

            }
            else
            {               
                filter.Add(PredicateFactory.CompareValue(PMS.DAL.PatientMedicalStaffFieldIndex.IsDeleted, ComparisonOperator.Equal,false));
                filter.AddWithAnd(PredicateFactory.CompareValue(PMS.DAL.PatientMedicalStaffFieldIndex.FK_PatientID, ComparisonOperator.Equal,Manager.CurrentPatient.Patient_ID));
            }

            ISortExpression sorter = new SortExpression();
            sorter.Add(SortClauseFactory.Create(PMS.DAL.PatientMedicalStaffFieldIndex.IsPrimary,SortOperator.Descending));
                
            mPatientMedicalStaffCol = new PatientMedicalStaffCollection();
            mPatientMedicalStaffCol.GetMulti(filter,0,sorter,relationsToUse);

Any help would be greatly appreciated.

I am using SelfService.

Thanks Hameed

Hameed
User
Posts: 34
Joined: 02-May-2005
# Posted on: 25-Jul-2005 15:07:22   

Its ok. No need to reply I've fixed the issue.

It just need some more persistance and standing out of the box.

simple_smile

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 25-Jul-2005 15:27:32   

Glad it's solved! simple_smile

Frans Bouma | Lead developer LLBLGen Pro