Skip to main content
Question

How to use Where condition in PXDatabase Select

  • November 21, 2025
  • 4 replies
  • 56 views

Forum|alt.badge.img+3

Hi Team,
Using PXDatabase Select query, trying to fetch records

List<Table> imgAllprocessed = PXDatabase.Select<Table>().RowCast<Table>().ToList();

Could you please help to add Where condition to filter records 

4 replies

Forum|alt.badge.img+2

Hello ​@arthia You can use like this :

E.g.

Filter records with WHERE condition

var results = PXDatabase.Select<Table>(
new PXDataFieldRestrict(Table.fieldName, PXDbType.VarChar, "VALUE", PXComp.EQ)
).RowCast<Table>().ToList();

With Integer

var results = PXDatabase.Select<Table>(
new PXDataFieldRestrict(Table.inventoryID, PXDbType.Int, 123, PXComp.EQ)
).RowCast<Table>().ToList();

Multiple Condition

var results = PXDatabase.Select<Table>(
new PXDataFieldRestrict(Table.status, PXDbType.VarChar, "A", PXComp.EQ),
new PXDataFieldRestrict(Table.active, PXDbType.Bit, true, PXComp.EQ)
).RowCast<Table>().ToList();
Note : 
  • PXDatabase.Select<T> bypasses DAC logic and caches. it hits SQL directly.

  • Always use PXDataFieldRestrict for filtering.

  • Never use business logic here (because graph is bypassed).

I hope it helps.


Forum|alt.badge.img+3
  • Author
  • Varsity I
  • November 26, 2025

Hi ​@Abhishek Niikam , Thank you for your response.

I tried with the suggested BQL query but I’m facing issue, shared the details in screenshot

 


Forum|alt.badge.img+2

Hello ​@arthia You can try this if your field name is not different from the property name:

var results = PXDatabase.Select<KNDCSPImageDetails>(new PXDataFieldRestrict(nameof(KNDCSPImageDetails.IsProcessed), PXDbType.Bit, 0, PXComp.EQ)).RowCast<KNDCSPImageDetails>().ToList();

var results1 = PXDatabase.SelectMulti<KNDCSPImageDetails>(new PXDataFieldRestrict(nameof(KNDCSPImageDetails.IsProcessed), PXDbType.Bit, 0, PXComp.EQ)).RowCast<KNDCSPImageDetails>().ToList();

I hope it helps!

 


Forum|alt.badge.img+3
  • Author
  • Varsity I
  • November 26, 2025

Hi ​@Abhishek Niikam , Thank you sharing some more BQL approaches, still facing issue.