LINQ experience (17) -- the dynamic query example of the LINQ to SQL statement:
Code
Using (Employeedbdatacontext DB = New Employeedbdatacontext ())
{
VaR L = DB. vw_employees;
Parameterexpression Param = Expression. parameter ( Typeof (Vw_employee ), " P " );
Expression left = Expression. Property (Param, Typeof (Vw_employee). getproperty ( " Emplid " ));
Expression right = Expression. Constant (EMP. emplid );
Expression Filter = Expression. Equal (left, right );
Expression Pred = Expression. Lambda (filter, Param );
Expression expr = Expression. Call ( Typeof (Queryable ), " Where " ,
New Type [] { Typeof (Vw_employee )},
Expression. Constant (L), Pred );
Iqueryable < Vw_employee > Query = DB. vw_employees.asqueryable (). provider. createquery < Vw_employee > (Expr );
Return Query. tolist ();
}
Lambda: http://www.cnblogs.com/killuakun/archive/2008/08/03/1259389.html http://www.cnblogs.com/terrylee/archive/2008/08/01/custom-linq-provider-part-1-expression-tree.html http://www.cnblogs.com/ninputer/archive/2009/08/28/expression_tree1.html http://www.cnblogs.com/126/archive/2007/08/15/857193.html Lambda Expression Tree: build your own LINQ provider (on): Expression Tree reveal how to build your own LINQ provider (in ): iqueryable and iqueryprovider LINQ to SQL advanced series (6) How to Use object to dynamically query and save log Expression Tree (I) ==> NHB
Http://www.kontac.net/site/
Http://www.cnblogs.com/lyj/archive/2008/11/10/1330542.html