Prefetchpath for 3 rd or 4rth level relation

Posts   
 
    
wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 27-Mar-2008 04:08:12   

Hello I have been able to prefetch related entities and is working ok but here is my problem:

I have a purchases DB where I have this structure

PERSON |___SUPPLIER |___PURCHASE_ORDER |_PO_DETAIL |___RECEPTION | ____RECEPTION DETAILS

So I need for a report to get a table to be put in a grid where I have all the reception details, then load foreach detail some fields from Reception that is referenced to the Purchase Order, that is referenced to Supplier (supplier gets its name from a PERSONS table.

I created some custom properties like SupplierName in Supplier (from Person table), and so on, but how can I access a Field in PERSON table from RECEPTION DETAILS???

I am not sure if this is right


DataAccessAdapter adapter = new DataAccessAdapter();
            IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.ReceptionDetail);
            prefetchPath.Add(ReceptionDetailEntity.PrefetchPathMaterials);
            prefetchPath.Add(ReceptionEntity.PrefetchPathPurchaseOrderDetail).SubPath.Add(PuechaseOrderDetailEntity .PrefetchPathPuechaseOrder).SubPath.Add(PuechaseOrderEntity.PrefetchPathSupplier).SubPath.Add( SupplierEntity.PrefetchPathPerson);
        
            adapter.FetchEntityCollection(_desempaqueDetalle, null,prefetchPath);
            adapter.CloseConnection();
            dataGridView1.DataSource = _desempaqueDetalleSrc;


This is working but how can I get a BIG TABLE where all the fields are joined ? I need to have in the Reception_Detail the name of the supplier that is in the PERSON table, is that possible??

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Mar-2008 05:31:36   

This is working but how can I get a BIG TABLE where all the fields are joined ? I need to have in the Reception_Detail the name of the supplier that is in the PERSON table, is that possible??

You could write a ReceptionDetail property that returns the PersonName:

public string PersonName
{
     get {
          if (Reception != null
              && Reception.PurchaseOrderDetail != null
              && Reception.PurchaseOrderDetail.PurchaseOrder != null
              && Reception.PurchaseOrderDetail.PurchaseOrder.Supplier != null
              && Reception.PurchaseOrderDetail.PurchaseOrder.Supplier.Person != null)                   
              {
                   return Reception.PurchaseOrderDetail.PurchaseOrder.Supplier.Person.Name;
              }
     }
}

If you need a more complex joined read-only structure, you could opt for a DynamicList.

David Elizondo | LLBLGen Support Team