Session MainSession = new Session();
XPQuery<Customer> customersQuery = new XPQuery<Customer>(MainSession);
var customers = from c in customersQuery
where c.Name == "John"
foreach (Customer customer in customers)
Dim MainSession As New Session()
Dim customersQuery As XPQuery(Of Customer) = New XPQuery(Of Customer)(MainSession)
Dim customers = from c in customersQuery where c.Name = "John" select c
For Each customer As Customer In customers
For more examples on using the XPQuery<T> class, refer to the LINQ to XPO knowledge base article.
XPO LINQ expressions are processed on the database server side and only the requested objects are loaded into the application.