惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
博客园 - 三生石上(FineUI控件)
V
V2EX
有赞技术团队
有赞技术团队
V
Visual Studio Blog
小众软件
小众软件
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
量子位
T
Tailwind CSS Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
Cisco Talos Blog
Cisco Talos Blog
I
Intezer
Project Zero
Project Zero
A
Arctic Wolf
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
L
Lohrmann on Cybersecurity
S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tor Project blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Security @ Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 热门话题
G
GRAHAM CLULEY
Help Net Security
Help Net Security
N
News | PayPal Newsroom
W
WeLiveSecurity
G
Google Developers Blog
Microsoft Security Blog
Microsoft Security Blog
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
C
Check Point Blog

博客园 - InFuture

变成百万富翁的二十五种方法 今天终于测试解决了WCF传递大数据量的问题 关于工作流设计方面的一些经验总结 Telnet客户端 字符串表达式求值(转) silverlight DataGrid模板列的动态生成 关于事件处理的完整框架Event,delegate,event args,无图有真相。 关于树形结构父类查子类,子类查父类的方法 最近准备整理一下手头资料,开发一个工作流和表单管理系统 今天装好了window 7 Silverlight 客户端如何访问WCF 如何让用户控件占满全部页面,silverlight用户控件开发问题 wpf 数据绑定有关讲解 ASP.NET 3.5 Extensions: Dynamic Data Web Site 要點整理(转载) 免费的微软OneCare防病毒软件 Visual Studio 2008 SP1: EntityDataSource for ASP.Net (转载) 今天装了VS2008 Sp1!真是非常激动!(VS2008 sp1下载地址) ASP.NET里的支架:Dynamic Data Support(转载) VS2008的黑色皮肤
Visual Studio 2008 SP1: EntityDataSource Where Clause(转载)
InFuture · 2008-08-22 · via 博客园 - InFuture

Visual Studio 2008 SP1: EntityDataSource Where Clause

This post in one of a series of blog posts about SP1 of Visual Studio 2008 and .Net Framework 3.5.

In the previous post about the EntityDataSource I've showed how to use it in a very basic way, which meant that I didn't customize the EntityDataSource at all. In this post I'll show how to filter the displayed entities by adding a where clause expressed by an Entity SQL statement.

EntityDataSource Where

Taking from where I finished in the last post, I now want to filter the customers by their city, according to the city that was selected in a listbox control. To so that:

1. Add a listbox control that contains items for filtering the list of entities. For example, if we want to filter customers by city, we will add a listbox similar to:

<asp:ListBox ID="list" runat="server" AutoPostBack="true">

    <asp:ListItem Text="Tel Aviv" Value="Tel Aviv" />

    <asp:ListItem Text="Haifa" Value="Haifa" />

</asp:ListBox>

2. Go to the property grid of the EntityDataSource and locate the Where property. In this property, write an Entity SQL statement that may have parameters that start with @, or use the Expression Editor to do this. For example: it.City == @city

EntityDataSource Where Bug Expression Editor

3. Using the Add Parameter button in the Expression Editor, add a new parameter with the same name as you used in the where clause, and choose the parameter source. You can choose to take the parameter value from a session value, from another control's value, and some other options. For this sample, choose Parameter Source = Control, and from the ControlID dropdown, select the listbox control ID.

EntityDataSource Where Parameter Source

Note: In the Beta of SP1 of Visual Studio 2008 and .Net Framework 3.5 there is a known bug that prevents you from using this Expression Editor and choose the parameter source, which will be fixed when we RTM. For now, after specifying the Where Expression, switch to the source view and add the parameters manually:

<asp:EntityDataSource ID="EntityDataSource" runat="server" ConnectionString="name=BankEntities"

  ContextTypeName="" DefaultContainerName="BankEntities" EnableDelete="True" EnableInsert="True"

  EnableUpdate="True" EntitySetName="Customers" Where="it.City == @city">

  <WhereParameters>

    <asp:ControlParameter Name="city" Type="String" ControlID="list" PropertyName="SelectedValue" />

  </WhereParameters>

</asp:EntityDataSource>

4. Run and browse to the page, and select one of the values in the listbox. The data shown in the gridview will be refreshed according to the where clause and the selected value of the listbox.

EntityDataSource Where ControlParameter

Enjoy!