停止动态数据实体 Web 应用程序中的筛选器显示
我目前正在 VS2008 SP1 中尝试动态数据实体 Web 应用程序项目类型,在阅读了许多教程后,这些教程为我到目前为止不需要解决问题的问题提供了有用的建议,但我在第一个障碍上就遇到了困难。
在数据库中,我制作了我的实体模型,我决定从一个名为“Companies”的表开始,只是为了看看我是否可以将显示调整为这个小表的令人满意的形状。 Companies 表有一个名为“contactid”的列,该列导致“contacts”表中填充有各种联系信息的记录。
默认创建的实体数据模型猜测一个公司可能有许多联系人记录。因此,它试图提供帮助,并在页面上添加一个“联系人”过滤器,使您可以查看共享由“联系人姓名”字段索引的一组特定联系信息的所有公司。
不幸的是,联系人表是一个多用途表,它还存储客户的联系信息,而且客户数量大约是公司数量的 1000 倍。所以Dropdown使得页面加载时间呈指数级增长,并且没有产生任何好处。
所以我想阻止过滤器出现。唯一的问题是我不知道如何关闭它。到目前为止,谷歌在此事上表现得很顽固,所以我想知道这里是否有人知道如何摆脱无用的过滤器。
I'm currently experimenting with the Dynamic Data Entity Web App Project type in VS2008 SP1 and after reading many tutorials which offer helpful advice for problems I so far have no need of a solution to I have fallen at the first hurdle.
In the DB I have made my entity model from I decided to start small with a table called "Companies" just to see if I could tweak the display into a satisfactory shape for this small table. The Companies table has a column called "contactid" which leads to a record filled with various contact information in a "contacts" table.
The default created Entity Data Model has guessed that One companies could have many contact records. So it tries to be helpful and add a "Contact" filter onto the page that allows you to see all the Companies that share a particular set of contact info indexed by the "Contact Name" field.
Unfortunately the contact table is a multi-purpose one that also stores contact info for customers and there are about 1000 times more customers than there are companies. So the Dropdown makes the page load time increase exponentially and produces no benefit.
So I'd like to just stop the filter from appearing. Only problem is I don't have a clue how to switch it off. Google is so far proving recalcitrant on the matter so I wondered if anyone in here knew how to get rid of a useless filter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近也遇到了同样的问题。我是动态数据应用程序模板的新手,很快就对其开箱即用的功能印象深刻。然而我也注意到了一些挫折,特别是你提到的那个。我的几个页面需要很长时间才能加载,当我发现这是由外键下拉填充引起的时,我花了一段时间才找到解决方案。
问题是这种行为对于网站的内部运作至关重要。这些外键下拉列表实际上驱动数据网格中的结果集。 (填充 ddlist,然后设置默认值,这会引发一个事件来过滤数据网格。)因此关键是改变此行为而不是禁用它。
我解决这个问题的第一个线索来自我在网上找到的一系列优秀博客。 向斯蒂芬·诺顿致敬
这个概念是创建一个元列属性并装饰元表部分类中的有问题的实体。 (我将我的DisableFilter 命名为DisableFilter)
因此,您最终将得到一个表和元表部分类定义,类似于:
我新创建的属性DisableFilter 装饰LeadAccount(我们的联系人表)集合。
装饰该列后,我通过添加对新属性的检查来更改ForeignKey.ascx 控件的基本行为。如果禁用过滤器,我只会使用默认项目填充 ddlist。
它不完全是我所说的完整解决方案,主要是过滤器的值不会包含用户友好的名称。我还没有费心去解决这个问题,但这应该会让你更接近解决你的问题。
I recently had the same issue. I am new to the Dynamic Data Application template and was quickly impressed by its out of the box functionality. However I noted a few set backs as well, specifically the one you mentioned. Several of my pages took forever to load, and when I disovered that it was caused by the foreign key drop down populates, it took me a while to find a solution.
The problem is this behavoir is essential to the inner workings of the web site. These foreign key dropdown lists actually drive the result set in the datagrid. (The ddlist is populated, then the default value is set, which raises an event to filter the datagrid.) So the key is to alter this behavoir instead of disabling it.
My first clue in solve this issue came from an excellent series of blogs I found on the web. Kudos to Stephen Naughton
The concept is to create a metacolumn attribute and decorate the problematic entities in your metatable partial classes. (I named mine DisableFilter)
So, you'll end up with a table and metatable partial class definition similar to:
My newly created attribute, DisableFilter, decorates the LeadAccount (Our Contact table) collection.
Once the column is decorated, I then altered the base behavior of the ForeignKey.ascx control by adding a check for the new attribute. If the filter is disabled, I only populate the ddlist with the default item.
Its not quite what I call a full solution, mainly the value of the filter will not contain a user friendly name. I haven't bothered to resolve this yet, but this should get you one step closer to solving your problem.