This project is read-only.

Usage

  1. Reference the assembly,for Linq to SQL user, reference System.Data.Linq.Dynamic.dll, for ALinq user, reference ALinq.Dynamic.dll, the assemblies can be found in the directory named binary.
  2. Import namespace.Import the required namespace named ALinq.Dynamic
  3. Create a query. The query is lazy load, it will not execute untill usaged, or the Execute method is called.
Example
var esql = "select p from Products";
var q = db.CreateQuery<Product>(esql); // Lazy Load
q.Execute();  //Immediately load

Case sensitive

The namespace, class name, member name, and custom define function are case sensitive.
Example
select p from Product as p
SELECT p FROM Product AS p
-- These esql statement are same 
select p from Product as p
select p from PRODUCT as p
-- These esql statements are NOT same.
select p.ProductId, p.ProductName from Product as p
select p.ProductID, p.ProductNAME from Product as p
-- These esql statements are NOT same.

NameSpace

Using Keyword
Use Using keyword can import the namespace, which can avoid the global identity.
Example
using NorthwindDemo;
select e.FirstName, e.LastName 
from Employee as e
Same As
select e.FirstName, e.LastName 
from NorthwindDemo.Employee as e
The default imported namespace
When use CreateQuery method create a query, ALinq Dynami will auto import the namespace of the dataContext instance.
var db = new NorthwindDemo.NorthwindDataContext();
var esql = "select e.FirstName, e.LastName from Employee as e";
var q = db.CreateQuery(esql)

Same As
var db = new NorthwindDemo.NorthwindDataContext();
var esql = @"using NorthwindDemo;
             select e.FirstName, e.LastName from Employee as e";
var q = db.CreateQuery(esql)

Identifier

The identifier is compose by one or more lectters, numbers or under lines, but the first characters must be letter.

Parameter

Named Parameter
var esql = @"select e from Employees as e
         where e.FirstName = @f and e.LastName = @l";
var q = db.CreateQuery(esql, new ObjectParameter("l", "mak"), new ObjectParameter("f", "mike"));
Ordered Parameter
var esql = @"select e from Employees as e
         where e.FirstName = @0 and e.LastName = @1";
var q = db.CreateQuery(esql, "mike", "mak");

To Be Continued

Last edited Mar 7, 2013 at 5:32 AM by ansiboy, version 3

Comments

No comments yet.