FetchEntityCollection in generated code

Posts   
 
    
BEDN
User
Posts: 14
Joined: 31-Jan-2007
# Posted on: 22-Mar-2007 10:02:17   

Hy,

I have created a partial class for one of my entitys, Lets call it MyEntity.

MyEntity Has Multiple fields , 2 of them have an FK pointing to the same table in the database and contain a from - To ID Value. MyEntity.StockIDFrom and MyEntity.StockIDTo.

In that partial class i try to fetch an entityCollection in a function,containing all the StockEntitys between that FromID and ToID.

In the Partial class it doesn't seem to be possible to create a DataAccessAdapter to fetch my entityCollection.

Can anybody help me?

TIA.

BEDN

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Mar-2007 10:13:54   

May I ask why do you want to do that? knowing the reason can help us suggest a better solution.

Thanks.

BEDN
User
Posts: 14
Joined: 31-Jan-2007
# Posted on: 22-Mar-2007 10:27:45   

I need this ofor a stock application.

I need to get all the stock locations between the first location selected (StockIDFrom) and the last location selected (StockIDTo).

A Stock location can be created at any given time and can be a location between the From and To Locations. Therefore I cannot subtract the ID of the from and the to location to get the count of all locations inbetween those 2.

So i need to run a function that finds out whtich locations are between them.

Practically:

fromLocation = WAREHOUSE1 - ZONE1

TOLocation = WAREHOUSE1 - ZONE2

now you have just 2 locations between these being ZONE1 and ZONE2 If an administrator adds a location WAREHOUSE1 - ZONE1 - B and WAREHOUSE1 - ZONE1 - C the situation changes and you will get 4 locations

SO if a want to display the number of locations between the From and To i will need to be able to calculate this.

I hope it is all clear?

TIA

BEDN

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Mar-2007 15:10:42   

Using the Adapter model aims to separate the Business Objects (EntityClasses) from the DAL(Adapter), so you can re-use the entities all over your layers without leting them know about the Database specific information or the database access adapter.

What you want seems to me as an implementation in the Business Layer, where you may have a method to which uses the DataAccessAdapter to query the needed data/entities, which can later be injected to some custom property created inside the entity classes.

BEDN
User
Posts: 14
Joined: 31-Jan-2007
# Posted on: 22-Mar-2007 15:14:19   

Ok,

indeed,

ths woould be an architectural mistake