MTrinder wrote:
So you are looking for something like
SELECT * FROM Person WHERE PersonId in
(SELECT PersonId FROM PersonRole WHERE RoleId IN
(SELECT RoleId FROM Role WHERE RoleName = 'MyRoleName'))
Like this (code from memory BTW...)
//a collection to hold the people
var people = new EntityCollection<PersonEntity>();
//an adapter
var adapter = new DataAccessAdapter();
// something to hold the relations (effictivly the joins to the other tables) and the filter value
var bucket = new RelationPredicateBucket();
//add the relations
bucket.Relations.Add(PersonEntity.Relations.PersonRoleUsingPersonId);
bucket.Relations.Add(PersonRoleEntity.Relations.RoleUsingRoleId);
//and the filter
bucket.PredicateExpression.Add(RoleFields.Name == myRoleName)
//get the data (you'll need to check the exact overload...!)
adapter.FetchEntityCollection(people,bucket);
Hopefully this should get you started.
Matt
Thanks, Matt..
The syntax looks a little different than what the code base I'm using uses..
EntityCollection<T> isn't referenced, but EntityCollectionBase<T> is.. but doesn't work in this example.
Here is an exmple of a typical query in this code base - this example below is clear, but it just queries 1 entity with some expressions as filters - I'm having an issue with the relations syntax;
PersonCollection inactiveStudents = new PersonCollection();
IPredicateExpression xFilter = new PredicateExpression(PersonFields.CustomerGuid == cust.Guid);
xFilter.AddWithAnd(PersonFields.IsStudent == true);
inactiveStudents.GetMulti(xFilter);
I'm not sure if it's real differences between your example and this - or just syntax preference going on here.
Thanks,
Jay