SQL Conversion

Posts   
 
    
Cutlass
User
Posts: 1
Joined: 18-May-2010
# Posted on: 18-May-2010 02:08:18   

Hi: newbe here!

How do I convert this SQL? Select * From FlightCargoCompartment Where FlightID = 3293444 And (Quantity <> 0 OR Weight <> 0)

this is what I have so far:

DataAccessAdapter adapter = new DataAccessAdapter(); EntityCollection flightCargoCompartmentsCurrent = new EntityCollection(new FlightCargoCompartmentsEntityFactory()); RelationPredicateBucket bucket = new RelationPredicateBucket(); bucket.PredicateExpression.Add(PredicateFactory.CompareValue(FlightCargoCompartmentsFieldIndex.FlightID, ComparisonOperator.Equal, flightID)); // sort the answer set by Euipment ID and Cargo Type ID ISortExpression sorter = new SortExpression( SortClauseFactory.Create(FlightCargoCompartmentsFieldIndex.EquipmentCompartmentID, SortOperator.Ascending)); sorter.Add(SortClauseFactory.Create(FlightCargoCompartmentsFieldIndex.CargoTypeID, SortOperator.Ascending)); adapter.FetchEntityCollection(flightCargoCompartmentsCurrent, bucket, 0, sorter);

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-May-2010 06:09:34   

What LLBLGen version are you using? Could you please try this:

DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection<FlightCargoCompartmentsEntity> flightCargoCompartmentsCurrent = new EntityCollection<FlightCargoCompartmentsEntity>();

//filter
RelationPredicateBucket bucket = new RelationPredicateBucket();                                     
bucket.PredicateExpression.Add(FlightCargoCompartmentsFields.FlightID == flightID); 
bucket.PredicateExpression.Add(FlightCargoCompartmentsFields.Quantity != 0
     | FlightCargoCompartmentsFields.Weight != 0);


// sort the answer set by Euipment ID and Cargo Type ID             
ISortExpression sorter = new SortExpression();
sorter.Add(FlightCargoCompartmentsFields.EquipmentCompartmentID | SortOperator.Ascending);
sorter.Add(FlightCargoCompartmentsFields.CargoTypeID | SortOperator.Ascending);

// fetch
adapter.FetchEntityCollection(flightCargoCompartmentsCurrent, bucket, 0, sorter);
David Elizondo | LLBLGen Support Team