Projection - Datatable

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 02-Jul-2010 12:26:26   

Framework: LLblGenRuntime LLblgen Ver 3.0 oracle 9i/10g

Hi, My code is below var customers = new EntityCollection<AccountnatureEntity>(new AccountnatureEntityFactory()); var adapter = new DataAccessAdapter(); adapter.FetchEntityCollection(customers, null); // fetch all customers var customerView = new EntityView2<AccountnatureEntity>(customers); var projectionResults = new DataTable(); IPredicate filter = (AccountnatureFields.Flag == 0); customerView.Filter = filter; var propertyProjectors = new ArrayList(); customers.CreateProjection(propertyProjectors, projectionResults);

Problem: I just to fetch all records from table account nature with condition flag=0 and project the output to datatable. Tried my level best with available examples but not able to figure out what I am doing wrong.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 02-Jul-2010 14:35:44   

You need to add some Projectors to your propertyProjectors array


propertyProjectors.Add( new EntityPropertyProjector( AccountNatureFields.Field1, "Field1" ) );

Matt

shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 02-Jul-2010 14:38:35   

MTrinder wrote:

You need to add some Projectors to your propertyProjectors array


propertyProjectors.Add( new EntityPropertyProjector( AccountNatureFields.Field1, "Field1" ) );

Matt

I am trying to fetch all data with one filter " FLAG=0"

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Jul-2010 21:55:42   

Your property projectors list is empty. You can use EntityFields2.ConvertToProjectors to get the full list of projectors (one per field):

//fetch collection
var customers = new EntityCollection<AccountnatureEntity>(new AccountnatureEntityFactory());
var adapter = new DataAccessAdapter();
adapter.FetchEntityCollection(customers, null); // fetch all customers

// create the entityView
var customerView = new EntityView2<AccountnatureEntity>(customers);
IPredicate filter = (AccountnatureFields.Flag == 0);
customerView.Filter = filter;

// set the projectors
List<IEntityPropertyProjector> propertyProjectors =
            EntityFields2.ConvertToProjectors(customers.EntityFactoryToUse.CreateFields());

// create the projection
var projectionResults = new DataTable();
customers.CreateProjection(propertyProjectors, projectionResults);
David Elizondo | LLBLGen Support Team
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 03-Jul-2010 05:38:46   

daelmo wrote:

Your property projectors list is empty. You can use EntityFields2.ConvertToProjectors to get the full list of projectors (one per field):

//fetch collection
var customers = new EntityCollection<AccountnatureEntity>(new AccountnatureEntityFactory());
var adapter = new DataAccessAdapter();
adapter.FetchEntityCollection(customers, null); // fetch all customers

// create the entityView
var customerView = new EntityView2<AccountnatureEntity>(customers);
IPredicate filter = (AccountnatureFields.Flag == 0);
customerView.Filter = filter;

// set the projectors
List<IEntityPropertyProjector> propertyProjectors =
            EntityFields2.ConvertToProjectors(customers.EntityFactoryToUse.CreateFields());

// create the projection
var projectionResults = new DataTable();
customers.CreateProjection(propertyProjectors, projectionResults);

customers.CreateProjection(propertyProjectors, projectionResults);

Error "CreateProjection" Cannot resolve symbol

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Jul-2010 20:11:52   

My mistake, It should be

customerView.CreateProjection(...)
David Elizondo | LLBLGen Support Team
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 06-Jul-2010 06:00:49   

daelmo wrote:

My mistake, It should be

customerView.CreateProjection(...)

Thanks This worked fine