LINQ queries - activa/iridium GitHub Wiki

Iridium will try to translate LINQ query expression into server-side queries (if the data provider supports it). Currently this is supported by any SQL data provider.

Queries can be performed across relations and if possible the query will be translated to a server-side query with the appropriate joins.

The following expressions are supported in a LINQ Where() expression:

  • A <operator> B
    • A and B should be numeric, booleans, dates or strings
    • Supported operators: ==,!=,<,>,<=,>=,+,-,/,*,&&,||
  • A.Length where A is a string
  • A.StartsWith(B) where A and B are strings
  • A.EndsWith(B) where A and B are strings
  • A.Contains(B) where A and B are strings
  • A.B where B is a many-to-one relation of A (this can be chained)
  • One-To-Many predicates
    • A.B.Any(condition) (condition is an optional condition lambda expression)
    • A.B.Count(condition) (condition is an optional condition lambda expression)
    • A.B.All(condition) (condition is an optional condition lambda expression)

Examples:

var orders = DB.Orders;

from o in orders where o.OrderDate < DateTime.Today select o

from o in orders where o.OrderItems.Count() > 1 select o

from o in orders where o.OrderItems.Any(item => item.ProductID == "A") select o

from o in orders where o.OrderItems.Any() select o

from o in orders where o.Customer.Name.StartsWith("A") select o

// or any combination
from o in orders 
      where o.Customer.Name == "John Doe" 
          && o.OrderDate < DateTime.Today 
          && o.OrderItems.Any() select o
⚠️ **GitHub.com Fallback** ⚠️