PDA

View Full Version : [CLOSED] v2.0 Store with linq anonymous type



Aurelio
Mar 08, 2012, 4:50 PM
Hi, in the 2.0 i have a problem with the Store binding in very slow whit the anonymous type, in V1.2 it's work ok.

This is very slow and retrive an error comunication failure when StoreComuni.databind(), the query work ok;



var lstcomuni =
from t0 in database.CAPCOM
where (t0.CapComCom.StartsWith(pIniText))
select new
{
t0.CapComId,
t0.CapComCod,
t0.CapComCom
};
StoreComuni.DataSource = lstcomuni;
StoreComuni.DataBind();


This work ok, but select all the field from table:


var lstcomuni =
from t0 in database.CAPCOM
where (t0.CapComCom.StartsWith(pIniText))
select (t0);
StoreComuni.DataSource = lstcomuni;
StoreComuni.DataBind();


The table content 10.000 record and is filter average 200 - 300 record for query.

If define a Classe with the 3 field, it's work ok, the problem is the anonymous type..

Tanks

Aurelio

Vladimir
Mar 08, 2012, 6:05 PM
Can you prepare test sample? Instead SQL please use some memory data (for example, collection)

Aurelio
Mar 08, 2012, 7:28 PM
Hi, Vladimir, I'm investigating why when public the application on the web server, it works, but with visual studio in mode dedugging it's report error. I try to make a new database to see if the problem is here. Prepare a sample with data in memory to see if the problem persists.

Thanks

Aurelio

Daniil
Mar 08, 2012, 7:39 PM
Hi,

Sometimes I face such issue when VisualStudio launches an application very slow in debug mode.

Removing all breakpoints may help:
VS Main Menu => Tools => Delete All Breakpoints.

Aurelio
Mar 08, 2012, 8:14 PM
Hi, i have reply the problem:

Web page:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ARWebRevolution.WebForm1" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ext.NET v2 Example</title>

</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<ext:Store ID="Store1" runat="server" >
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="nome">
<Fields>
<ext:ModelField Name="nome" />
<ext:ModelField Name="rata" />
<ext:ModelField Name="costo" />
</Fields>
</ext:Model>
</Model>
<Sorters>
<ext:DataSorter Property="nome" />
</Sorters>
</ext:Store>
<ext:Viewport ID="Viewport1" runat="server" Layout="border">
<Items>
<ext:Panel ID="PanelNazioni" runat="server" Region="West" Width="300" BodyPadding="3"
Layout="FitLayout" >
<Items>
<ext:GridPanel ID="GridPanelProvince" runat="server" Title="Province" StoreID="Store1">
<ColumnModel>
<Columns>
<ext:Column runat="server" ID="nome" DataIndex="nome" Align="Left" Text="Nome" Flex="1"/>
<ext:Column runat="server" ID="Rata" DataIndex="rata" Text="Rata" Width="50" />
<ext:Column runat="server" ID="Costo" DataIndex="costo" Text="Costo" Width="50" />
</Columns>
</ColumnModel>

</ext:GridPanel>
</Items>
</ext:Panel>
<ext:FormPanel ID="FormPanelNazione" runat="server" ButtonAlign="Right" Height="185"
BodyPadding="10" Padding="3" Region="Center" Title="Nazioni...">
</ext:FormPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>


Code page:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ARWebRevolution.Query;
using Ext.Net;

namespace ARWebRevolution
{
public partial class WebForm1 : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
var lista = TestData(50);
var lista2 = from t0 in lista
select new
{
t0.nome,
t0.rata,
t0.costo
};
Store1.DataSource = lista2;
Store1.DataBind();
}



private static List<Employee> TestData(int count)
{
var firstNames = new string[] { "Ed", "Tommy", "Aaron", "Abe", "Jamie", "Adam", "Dave", "David", "Jay", "Nicolas", "Nige" };
var lastNames = new string[] { "Spencer", "Maintz", "Conran", "Elias", "Avins", "Mishcon", "Kaneda", "Davis", "Robinson", "Ferrero", "White" };
var ratings = new int[] { 1, 2, 3, 4, 5 };
var salaries = new int[] { 100, 400, 900, 1500, 1000000 };

var data = new List<Employee>();
var rnd = new Random();

for (int i = 0; i < count; i++)
{
var ratingId = rnd.Next(ratings.Length);
var salaryId = rnd.Next(salaries.Length);
var firstNameId = rnd.Next(firstNames.Length);
var lastNameId = rnd.Next(lastNames.Length);

var rating = ratings[ratingId];
var salary = salaries[salaryId];
var name = String.Format("{0} {1}", firstNames[firstNameId], lastNames[lastNameId]);
var rowEmp = new Employee{nome = name,rata = rating,costo = salary};
data.Add(rowEmp);

}

return data;
}

public class Employee
{
public string nome { get; set; }
public int rata { get; set; }
public int costo { get; set; }
}
}
}


Visual studio modal debug with anonymous type query
1)Load 50 record it's work OK
2)Load 100 record it's not work error Internet Explorer: impossibile visualizzare la pagina Web

Visual studio modal debug not anonymous:


protected void Page_Load(object sender, EventArgs e)
{
var lista = TestData(1000);
var lista2 = from t0 in lista
select (t0);
Store1.DataSource = lista2;
Store1.DataBind();
}


1)With 1000-2000 record it's work OK

In V1.2 anonymous work ok

Tanks
Aurelio

Vladimir
Mar 09, 2012, 10:09 AM
I tried with 100 and 1000 records and don't see any problems (test sample with anonymous type)
On my computer, the page with 1000 records is rendered in 0.138 ms

Try to use VS2010 profiler to determine bottle neck

Aurelio
Mar 11, 2012, 9:42 PM
Hi, Vladimir, the problem is my VS2010 debugger, VS2010 profiler execute the page and work ok, but in modal debug it's not work, V1.2 work ok, now investigate for my VS2010 debug.

The problem is my VS2010, close the post.

Thanks

Aurelio

Daniil
Mar 12, 2012, 11:34 AM
Please clarify did you try this?



Removing all breakpoints may help:
VS Main Menu => Tools => Delete All Breakpoints.

Aurelio
Mar 12, 2012, 12:06 PM
HI, Daniil, i have delete all breakpoint and execute many other setting on debugger options, but the problem persist, with 1.2v work ok, now i have install vs2011 beta, but i have the same problem, in modal debug the STORE1.databind() is slow and the page non loaded and retrive an error to IE. It's work ok without debugging (CTRL+F5).

Tanks
Aurelio

Daniil
Mar 12, 2012, 3:39 PM
Ok, thanks for the details.

Unfortunately, we have no more idea what might be wrong.

Aurelio
Mar 12, 2012, 5:00 PM
Hi Daniil, i have find the problem, it's the web.config !!!! (grrrr)

I remove from the web.config this:


<trust level="Medium"/>

and the work OK, this command slow the store.databind() with anonymous type.

Thanks

Aurelio

Daniil
Mar 12, 2012, 5:12 PM
Thanks for the update.

Well, it looks to be not an Ext.NET issue, but, anyways, good to know!