Adapter::FetchEntity - Non PK field ignored.

Posts   
 
    
jwijnker
User
Posts: 32
Joined: 09-Mar-2011
# Posted on: 01-Oct-2013 14:08:32   

Hi all,

I'm using LLBLGen 3.1 (Adapter) and have the following problem:

When I try to fetch an entity (using Adapter::FetchEntity(someEntity) ) any aditional field set in the entityToFetch is ignored during fetching.

Sample:


// Structure of used entities...

SomeEntity (SampleClass)
-----------------------------------
- id (int) PK
- tenantId (int)
- otherField(s) (any)

ITenantEnity (Interface)
------------------------------
- tenantId (int)


SomeTable
-------------------
id (PK) | tenantId | otherFields..
 1 |  25 | ...
 2 | 100 | ...

// id is PK
// tenantId is not part of the PK
var some = new SomeEntity() { id = 1, tenantId = 100};
adapter.FetchEntity(some);
....


A someEntity with id 1 gets fetched no matter the tenantId confused !!

How can I make sure all fields do matter when fetching a single entity without having to add the tenantId field to the PK, or having to fetch a collection and filter the collection?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 01-Oct-2013 20:33:55   

FetchEntity is used to fetch a single entity using it's PK.

You have to use adapter.FetchEntityCollection(collection, filter);

Passing a RelationPredicateBucket object containing the appropriate predicates and relations for filtering/