首页 新闻 会员 周边 捐助

linq表达式树构建的问题

0
悬赏园豆:40 [已关闭问题] 关闭于 2015-02-05 13:56

结果相当于实现

List<FavShopModel>.where(o=>o.zdit==42)

ParameterExpression pe = Expression.Parameter(typeof(FavShopModel), "o");
  Expression left = Expression.Property(pe, typeof(string).GetProperty("zdid", typeof(int)));
                            Expression right = Expression.Constant(s.zdid);
                            Expression e1 = Expression.Equal(right, left);

                            var results = queryableData.Provider.CreateQuery<FavShopModel>(e1).ToList();

                            MethodCallExpression whereCallExpression = Expression.Call(
                                typeof(Queryable), "Where",
              new Type[] { queryableData.ElementType },
              queryableData.Expression,
              Expression.Lambda<Func<string, bool>>(e1, new ParameterExpression[] { pe }));
                            results = queryableData.Provider.CreateQuery<FavShopModel>(whereCallExpression).ToList();
                            return results;

心好累,求指点

Cherbim的主页 Cherbim | 菜鸟二级 | 园豆:323
提问于:2014-12-12 17:01
< >
分享
所有回答(1)
0

看的好累,求详解

xmj112288 | 园豆:126 (初学一级) | 2014-12-12 17:40
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册