NPersist support Linq queries.

Samples:

Filter on properties
var result = from customer in ctx.Repository<Customer>()
             where customer.Name like 'A%'
             select customer;


Load spans
var result = from customer in ctx.Repository(new LoadSpan<Customer>("Name","Email"))
             select customer;


Simple subquery
var result = from customer in ctx.Repository<Customer>()
             where customer .Name like 'A%' &&
             customer.Orders.Count > 10
             select customer;


Complex subquery
var res = from cust in ctx.Repository<Customer>()
          where (from order in cust.Orders
                 where order.OrderDate ==
                 new DateTime(2008,01,01) && order.Total == 3.1
                 select order).Count > 0
          select cust;


Query parameters
Customer someCustomer = ....;
var res = from cust in ctx.Repository<Customer>()
          where cust != someCustomer
          select cust;

Last edited Feb 23, 2008 at 5:33 AM by Roggan, version 5

Comments

No comments yet.