Some thing about Lambda Expression and NHB

  example:
Some thing about Lambda Expression and NHB 代码
             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 :
 
 
 
   
 

你可能感兴趣的:(express)