LINQ Support

Starting from the PPJ Framework 2009 release we have added full native Language Integrated Query (LINQ) support to the SalArray type and both the SalTableWindow control and SalFormTableWindow form.

LINQ adds extremely powerful language features for querying and extracting data from data collections. With built-in LINQ support in the PPJ Framework migrated code automatically supports LINQ constructs on existing objects.


All dynamic array declarations based on SalArray<> support LINQ. Using LINQ on SalArray instances is as easy as using LINQ on any .NET collection:

SalArray<CCustomer> arCustomers = new SalArray<CCustomer();
...Populate array...
var ActiveCustomers = from c in arCustomers where c.Active = true
select c;

The code snippet above creates a collection ActiveCustomers populated by instances of CCustomer where the value of the member variable Active is equal to true.

TableWindow Controls

LINQ support in table windows is different from SalArray. SalTableWindows contain dynamic columns and multiple rows and the final content and structure of of a table window is not fully determined until runtime.

The LINQ implementation of the IEnumerable interface in SalTableWindow returns the rows contained in the table window as instances of SalTableRow. Cell values in the row instance can be accessed using the name or the reference of the column. The same example listed for the SalArray LINQ implementation would look like the following code for a table window control:

var ActiveCustomers = from r in tblCustomers 
    where r["colActive"].Number = "Y";

// or

var ActiveCustomers = from r in tblCustomers 
    where r[tblCustomers.colActive].Number = 1;

Using the column reference instead of the column name has the advantage to prevent broken references when the name of columns is changed since the compiler will enforce the symbol reference. However, using the column name as a string allows for more dynamic queries.


If you want to try out a bit of LINQ, you can take a look at LINQPad:

For many useful LINQ samples you can use this page:

Last updated