Visit Member

Use dot operator(.) can visit a member of instance, property, field and method. If the member is a collection, and can use brackets([]) to visit a element in the collection.

Visit Property

select o.OrderId, o.OrderDate from Orders as o
select o.OrderDate.Value.Year from Orders as o where o.OrderDate is not null

Visit Method

select o.OrderDate.Value.ToString('yyyy-MM-dd') as Date 
from Orders as o where o.OrderDate is not null

Visit Element

This example get the frist element in the OrderDetails collection, but required type of the member supports indexer.
var esql = "select o.OrderId, o.OrderDetails[0] as FirstOrderDetail from Orders as o";
db.CreateQuery(esql).Execute();

Visit Static Method

This example visit the static method named NewGuid in the System.Guid type.
select System.Guid.NewGuid() as Guid, e.FirstName from Employees as e

Visit DataContext Method

The GetFullName literal is a member method of the dataContext instance named db.
var esql = "select value GetFullName(e.FirstName, e.LastName) from Employees as e";
q = db.CreateQuery<string>(esql);

Visit DataContext Property

In this example, the Version literal is a property of the dataContext instance named db.
var esql = "select Version, e.FirstName from Employees as e";
var q = db.CreateQuery<IDataRecord>(esql);

Last edited Mar 8, 2013 at 11:28 AM by ansiboy, version 3

Comments

No comments yet.