实体框架中的动态查询 [英] Dynamic queries in entity frame work

查看:117
本文介绍了实体框架中的动态查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,我对MVC感兴趣,我对此有一个小疑问.
我想知道例如如何生成动态查询.
如果我要检索< 1500的项目,那么我要为此编写一个查询表达式.现在,如果我想提出更多建议,例如尺寸> 8和brand ==''Reebok''delivery = 2days,那我该怎么办.我为所有机会编写查询.用户可以通过多种方式询问查询如何动态地回答它们. 请发布任何答案和实时用法.
谢谢.

Hello Friends,I''m interested in MVC I have one small Doubt.
I want to know how to generate dynamic queries for example.
If i want to retrive items <1500 then i write a query expression for that .now if i like to make more suggestions like size>8 and brand==''Reebok'' delivery=2days then what i have to do.should i write query for all the chances.there will number of ways the user can ask query how to answer them dynamically.i heard about expression tress but.
Plz post any answers and real time usage of it.
Thanks.

推荐答案



你问的很简单.

IQueryable是可以帮助您完成此操作的类型.

IQueryable的详细信息: http://blogs.msdn.com/b/mattwar/archive/2007/07/30/linq-building-an-iqueryable-provider-part-i.aspx [ http://www.albahari.com/nutshell/predicatebuilder.aspx [使用LINQ-to-Entities进行动态查询和表达式 [ ^ ]
Hi,

what you asking is very simple.

IQueryable is the type which will help you to do the same.

In depth details of IQueryable : http://blogs.msdn.com/b/mattwar/archive/2007/07/30/linq-building-an-iqueryable-provider-part-i.aspx[^]

In sort IQueryable will execute the query when you call (ToList,ToArray etc) till that time it will just build the query so you can manipulate the same.

Predicates Builder : http://www.albahari.com/nutshell/predicatebuilder.aspx[^]

It will serve your purpose :Dynamic Querying with LINQ-to-Entities and Expressions[^]


这篇关于实体框架中的动态查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆