Hi.. I've got a query I can't get to run correctly..
I've got 4 Entities that are tied together as follows
RequisitionRequestEntity PersonGuid)
PersonEntity (has PersonGuid)
PersonRole (has PersonGuid and RoleGuid)
RoleGuid (has RoleGuid)
All of these have ClientGuid
And I've got a RelationsCollection
- RequisitionRequestEntity.Relations.PersonEntityUsingPersonGuid
Just that works find.. I can get the Requisitions by Client by simply .
And I can add a Relation to PersonRole to filter by a list of filters keying off of RoleGuid ;
PersonRoleEntity.Relations.PersonEntityUsingPersonGuid
and then by looping through and appending the filter like;
filter.AddWithAnd(PersonRole.Fields.RoleGuid == roleguid)
However, I can't get a valid list when I try to get all Requistions for Peopel that aren't associated with a particular set of Roles, referenced in PersonRoles
and then looping through to add to the filter
filter.AddWithAnd(PersonRole.Fields.RoleGuid != roleguid)
And LLBGen things I'm missing here? Have I got my relations confused?
Thanks for any help,
Jay
Adding some code to help with my convoluted description;
IPredicateExpression filter = new PredicateExpression(RequisitionRequestFields.IsActive == true);
filter.AddWithAnd(RequisitionRequestFields.Purge == false);
filter.AddWithAnd(RequisitionRequestFields.NextFiscalYear == false);
RelationCollection rels = new RelationCollection();
rels.Add(RequisitionRequestEntity.Relations.PersonEntityUsingPersonGuid);
filter.AddWithAnd(PersonFields.CustomerGuid == FSPrincipal.GetCurrentPricipal().CustomerGuid);
rels.Add(PersonRoleEntity.Relations.PersonEntityUsingPersonGuid);
IPredicateExpression roleFilter = new PredicateExpression();
roleFilter.Add(!(PersonRoleFields.RoleGuid == new Guid("0cc69821-ba74-49cb-a28a-b2f812e5d1d1")));
filter.AddWithAnd(roleFilter);
reqs.GetMulti(filter, 25, new SortExpression(RequisitionRequestFields.Number | SortOperator.Ascending), rels, pageNumber, 25);
reqs.Items.Count <- returns 3 (which should be 13)
reqs.GetDbCount(filter, rels) <- returns 633 (which I'm not sure how it is figuring out)
reqs.Items.Count <- returns 3 (which should be 13)
reqs.GetDbCount(filter, rels) <- returns 633 (which I'm not sure how it is figuring out)
here is the SQL query that works
select * from RequisitionRequest r, Person p where
r.IsActive = 1 and r.Purge = 0 and r.NextFiscalYear = 0 and p.CustomerGuid = '9A9ED07C-3DA2-4D71-BE0E-5EC05A42869B'
and r.PersonGuid = p.guid and p.guid not in (
select PersonGuid from PersonRole where RoleGuid = '0cc69821-ba74-49cb-a28a-b2f812e5d1d1')