Can EntityField2 be used in FieldCompareSetPredicate ?

Posts   
 
    
rracer99
User
Posts: 58
Joined: 11-Mar-2007
# Posted on: 16-Jun-2007 12:50:45   

Can an EntityField2 be used instead of a literal value when using a predicate?

For example, I have a several IPrefetchPathElements that I am building for a large query:

In this case, if I use a literal value instead of using "ClientContactsFields.ClientContactId", the query will work. However by using "ClientContactsFields.ClientContactId" instead, I get and error "The multi-part identifier "client_contacts.client_contact_id" could not be bound."

The problem is I do not have the value of "ClientContactId" yet, because I am assembling the prefetch paths. I am hoping not to have to add a query to get the value first (it seems like an unnecessary trip to the DB)




                ppeClientPlans.Filter.Add(
                    new FieldCompareSetPredicate(ClientPlansFields.ClientPlanId, null,
                                                 ClientContactClientPlansRolesRelFields.ClientPlanId, null,
                                                 SetOperator.In,
                                                 (ClientContactClientPlansRolesRelFields.ClientContactId ==
                                                  ClientContactsFields.ClientContactId)
                        ));






How can you compare to a field in another Entity, when you have not yet retrieved the value?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39913
Joined: 17-Aug-2003
# Posted on: 17-Jun-2007 10:26:07   

As Clientcontacts is a different entity, you also should pass in a RelationCollection with the relation between ClientContactClientPlansRolesRel and ClientContacts. Do that by using a different overload of the FieldCompareSetPredicate which accepts a relationcollection as well. simple_smile

Frans Bouma | Lead developer LLBLGen Pro