Hi All,
I want to translate this SQL, where there's no relation between T_Client and T_ClientProcess.
//delete T_UserRight
// where not exists (Select userRightId
// FROM T_UserRight b, T_USER, T_Client, T_ClientProcess
// Where T_UserRight.userRightId = b.userRightId
// and b.userId = T_User.userId
// and T_Client.clientId = T_User.clientId
// and T_Client.clientId = T_ClientProcess.ClientId )
I've come up with this
DynamicRelation dr = new DynamicRelation(EntityType.TUserRightEntity, JoinHint.Right, EntityType.TUserRightEntity, "r1", "r2", TUserRightFields.UserRightId.SetObjectAlias("r1") == TUserRightFields.UserRightId.SetObjectAlias("r2"));
DynamicRelation drClientProcess = new DynamicRelation(EntityType.TClientEntity, JoinHint.Inner, EntityType.TClientProcessEntity, String.Empty, String.Empty, TClientFields.ClientId == TClientProcessFields.ClientId);
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.Relations.Add(dr);
bucket.Relations.Add(drClientProcess);
bucket.Relations.Add(TUserEntity.Relations.TClientEntityUsingClientId, JoinHint.Inner);
bucket.Relations.Add(TUserRightEntity.Relations.TUserEntityUsingUserId, JoinHint.Inner);
bucket.PredicateExpression.Add(TUserRightFields.UserRightId.SetObjectAlias("r1") == DBNull.Value);
adapter.DeleteEntitiesDirectly("TUserRightEntity", bucket);
Relation at index 1 doesn't contain an entity already added to the FROM clause. Bad alias?
I've got this exception when I'm running this...
Any clues someone?