pvilanova wrote:
Walaa:
I've checked the example but i was not able to project any prefetch path at all.
The problem with this code,
foreach (IPrefetchPathElement2 pre in _InstrumentDS.PrefetchPathToUse)
foreach (EntityField2 fie in pre.EntityFactoryToUse.CreateFields())
propertyProjectors.Add(new EntityPropertyProjector(fie, fie.Name));
is pre.EntityFactoryToUse == null
Any ideas?
Thank you very much. Regards.
Are you sure you tried the Hierarchical Projection example? coz that indeed should work:
// -- the projectionData to fill
List<IViewProjectionData> projectionData = new List<IViewProjectionData>();
// -- setup projections per type.
// customers (the root type)
List<IEntityPropertyProjector> customerProjections = EntityFields2.ConvertToProjectors(
EntityFieldsFactory.CreateEntityFieldsObject(EntityType.CustomersEntity));
projectionData.Add(new ViewProjectionData<CustomersEntity>(customerProjections, null, true));
// orders
List<IEntityPropertyProjector> orderProjections = EntityFields2.ConvertToProjectors(
EntityFieldsFactory.CreateEntityFieldsObject(EntityType.OrdersEntity));
projectionData.Add(new ViewProjectionData<OrdersEntity>(orderProjections, null, false));
// employee
List<IEntityPropertyProjector> employeeProjections = EntityFields2.ConvertToProjectors(
EntityFieldsFactory.CreateEntityFieldsObject(EntityType.OrderDetailsEntity));
projectionData.Add(new ViewProjectionData<OrderDetailsEntity>(employeeProjections));
// -- get the DataSet results (here, _customerDS is a LLBLGenProDataSource2
DataSet result = new DataSet("projectionResult");
_customersDS.EntityCollection.CreateHierarchicalProjection(projectionData, result);
That assumes:
- The data is fetched and ready to use in your LLBLGenProDataSource2
- You know the prefetched graph and what types of that graph you want to project to the result DataSet.
Also, as you want a Hierarchical projection (root entity + prefetchtPaths) the result should be a DataSet, not a DataView
Hope helpful