views:

381

answers:

1

Hi all,

We are currently using Dynamic Data website for one of our project. we have found that Insert page was taking much time to load and on analysis we have found the LINQ datasource is fetching all the records for the current table when the insert page is loaded. I have found this through OnSelected event of LINQ datasource on the Insert page.

ASPX <%@ Page Language="C#" MasterPageFile="~/Site.master" CodeFile="Insert.aspx.cs" Inherits="Insert" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />

    <h2>Add new entry to table <%= table.DisplayName %></h2>

    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                HeaderText="List of validation errors" />
            <asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="DetailsView1" Display="None" />

            <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="DetailsDataSource" DefaultMode="Insert"
                AutoGenerateInsertButton="True" OnItemCommand="DetailsView1_ItemCommand" OnItemInserted="DetailsView1_ItemInserted"
                CssClass="detailstable" FieldHeaderStyle-CssClass="bold">
            </asp:DetailsView>

            <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableInsert="true"  
                onselected="DetailsDataSource_Selected">
            </asp:LinqDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

protected void DetailsDataSource_Selected(object sender, LinqDataSourceStatusEventArgs e)
    {
\\ e.Result is fetching some 76k record from DB
    }

How do we prevent this ? is this by design??

Any idea??

A: 

If you do not specify a value for the Select property, the LinqDataSource control returns all the properties (columns) from the class that represents the database table. Reference URL http://msdn.microsoft.com/en-us/library/bb470363.aspx

try to resolve problem using this.

protected void  DetailsDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    NewsDataContext db = new NewsDataContext();
    e.Result = db..Take(0); //this will return no row...
}
Muhammad Akhtar
This is my LINQDataSource, <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableInsert="true" onselected="DetailsDataSource_Selected"> </asp:LinqDataSource>I didnt get you how to remove the select method..
Plz post ur complete aspx page source
Muhammad Akhtar
ASPX code updated.Pls check.