Speeding Up LinqDataSource

Mar 4, 2011

Greetings, I have a following question. Suppose where are two tables in the database:

Clients(
id,
name,
address)
Orders(
id,
name,
desc,
datemodified,
client_id)

The second one references the first one, that is each order is assigned to the client. Now suppose I have an .aspx page with a LinqDataSource for Orders table, and a GridView that uses this datasource and displays a table with a following columns:

Order name.
Order desc.
Client name.
Client address.

As far as I understand, the Linq to SQL is designed in such a way, that by default it does not load any associated entities, it only does it when a child property is requested. So, when a page is loaded, the following situation will occur:

First query will retrieve the records from the Orders table. For each row displayed by GridView an additional query will be performed when one of the client properties is requested. Therefore, if we have 100 orders, this means will perform 101 queries instead of one (or even maybe 201, if a query will be performed for each client property)? How to avoid this and make LinqDataSource load all the required fields by a single query? Right now I see the only workaround for this problem - use an SqlDataSource with a join query, that will retrieve all required fields at once.

View 2 Replies


Similar Messages:

Binding Data From LinqDataSource To Textbox / How To Bind Texbox To One Property From Linqdatasource

Sep 1, 2010

How I can bind texbox to one property from linqdatasource?

I mean something like databinding contols in c# app

View 1 Replies

ADO.NET :: Speeding Up The Entity Framework?

Nov 18, 2010

I am working on a project that converts our enterprises code library so it uses the entity framework.

We use a ControllerFactory that "generates" controllers. These controllers contain the business logic of our enterprise. To avoid the problem of context conflicts (An object of one context that needs to be added to a new context, bla bla bla), we create a new Entity Context for each ControllerFactory we instantiate. All the controllers that are generated from the ControllerFactory use the same Entity Context for fetching and saving data.

Now, we have added a constructor to the ControllerFactory to make it Read-Only (Context.SaveChanges can't be executed) so it is a little bit safer and it doesn't save things we don't want to save when loading data to show to the user.

Then I started thinking about performance. Since the Context is never saved in a Read-Only factory, I have already disabled the state tracking of some Entities to speed things up.

But I wondered if we could improve the speed even more.

Since locking is not nescessary for only fetching entities, I would like the Entity Framework to add the WITH (NO LOCK) element to the SQL SELECTs it creates. But I Have found out that this only works when using transactions, and I can not use one transaction for the whole ControllerFactory.

View 2 Replies

C# - Speeding Up LINQ To SQL Code?

Apr 1, 2011

I am developing an ASP.NET where I need to display each purchase for every account in a GridView (so basically each purchase links to an account).

The problem is, we have over 6000 suppliers (granted, these can be filtered down to around 1000 which the customer will usually do), each of whom will have a few transactions. So you can imagine the time it takes to bind this data is very long - in fact, occasionally the SQL server times out. Sadly I cannot use paging, as all the data needs to be displayed in one page.

What I'm doing is similar to the code below (not at my machine so can't copy exactly)

IEnumerable<Account> accs = (from s in dc.Accounts select s);
foreach (Account acc in accs)
{
IEumerable<Purchases> purchs = (from s in dc.Purchases where s.AccountID == acc.ID select s);
double 30daysval;

[Code].....

Is there a faster way of doing this, perhaps using join's in LINQ or something? I know this may be a bit hopeless seeing as the data involved is huge, and that displaying a couple of thousands rows on a single page is fairly absurd, but that's what I've been told to do...

View 5 Replies

Speeding Up Gridview Displays?

Mar 3, 2010

I'm making a program that runs on a timer, checks queues for new report requests, runs them, and then marks them as done.

I was asked to show the entire queue in a gridview instead of just the ones that haven't been run yet. Showing them all slows display down - blinks off, waits, and comes back on with each timer tick. Only a few people in house will see this prog.

Is there any way a vb.net program can be run as an exe and not accessed over the web to maybe make it faster ?

Is there any easy way to reduce the blink between redisplays ?

View 1 Replies

WCF / ASMX :: Speeding Up Response Time?

Jun 30, 2010

why classic asp pages run so much faster than consuming a web service in .net?

I have a classic asp page that consumes a web service like so:

[Code]....

I run a log of every transaction and the time from call of the page to finish is ALWAYS between 1 and 2 seconds.However, when I try to consume the web service through .net like so:

[Code]....

This way takes on average at LEAST 10 seconds. Sometimes less, but not often.

I guess I just assume it should be the other way around. How can i speed this up? Seriously, don't make me stick to classic asp pages!

View 6 Replies

C# - Dynamic Columns With LinqDataSource?

Aug 24, 2010

Im using LinqDataSource like that:

<asp:LinqDataSource ID="LinqDataSource3" runat="server" OnSelecting="LinqDataSource3_OnSelecting">
</asp:LinqDataSource>
And I have ASPxGridView
<dxwgv:ASPxGridView ID="ASPxGridView2" ClientInstanceName="ASPxGridView2Client"
runat="server" AutoGenerateColumns="False"
DataSourceID="LinqDataSource3">
</dxwgv:ASPxGridView>

In this way Im able to add columns dynamically while handling onSelecting event:

protected void LinqDataSource3_OnSelecting(object sender, LinqDataSourceSelectEventArgs e)
{
MyModelDataContext context = new MyModelDataContext();
ASPxGridView grid = ASPxPageControl1.TabPages[3].FindControl("ASPxGridView2") as ASPxGridView;
if(grid.Columns.Count == 0){
GridViewDataTextColumn txtColumn1 = new GridViewDataTextColumn();
GridViewDataTextColumn txtColumn2 = new GridViewDataTextColumn();
txtColumn1.FieldName = "UserId";
txtColumn2.FieldName = "FirstName";
grid.Columns.Add(txtColumn1);
grid.Columns.Add(txtColumn2);
}
e.Result = from u in context.Users select new { UserId = u.UserId, FirstName = u.FirstName };
}

It is all made simply to test cause my idea is to have solution that makes it possible to use inqDataSource as a datasource for de ASPxGridView but join 2 or 3 tables and show results in this grid.

What I want to ask is if its good solution or is there any other better way to present some views made from couple of tables by join?

Second question is that I have Users and Group and I would like to have one table in which I would have two columns Name and Type For groups type would by group and for users type would be user. I dont have such a table in my database Is it possible to create specific class. Create List of objects of that class and fill it using linq query and the use it as linq data source for that grid ?

clas would be:

pseudocode:

Class MyClass {
string Type;
string Name;
}

or is there any other way to create such a table ?

View 1 Replies

DataSource Controls :: LinqDataSource?

Jun 11, 2010

Im trying to build a where clause in c# for a LinqDataSource, but I cant get it to work, heres my code

[Code]....

when I set category to 'Concerts' tyhe where clause is

'Category = Concerts'

this generates an error telling me there is no column called 'Concerts'. I assume I somehow have to enclose the search term in quotes, Ive tried single and double quotes, but nothing works.

View 5 Replies

DataSource Controls :: Using LIKE In A Linqdatasource?

Nov 16, 2010

So I need to take the literal "SELECT....FROM Bay....WHERE Warehouse=1 and ((BAY LIKE '1.0%' or BAY LIKE '2.0%'))I have set up a linqdatasource on my asp page and I want to bind that to a gridview. Here is the start of the HTML:

<asp:LinqDataSource
ID="dsBays"
runat="server"
ContextTypeName="CartonInventory.CartonInventoryDataContext"
EnableUpdate="True"

[code]...

How do I add a parameter so that it includes the LIKE statement?

View 1 Replies

Web Forms :: RadioButtonList And LinqDataSource?

May 5, 2010

ViewState is active and I have a RadioButtonList with DataSourceID to LinqDataSource.If I postback and cause event SelectedIndexChanged, I can read the SelectedValue property, but if the postback is caused by another control, SelectedValue its always empty...Note if I turn ViewState off, works fine, SelectedValue has always a non empty string...

View 3 Replies

Specify Stored Procedure In LinqDataSource?

May 18, 2010

I have a Listview that I want to read the results of a Stored procedure. I have created the DBML object with the table and the stored procedure. When I configure my LinqDataSource on the page I cannot specify the SProc - only the Table. Or do I need to do it in the Listview?

View 1 Replies

C# - Getting Xml Columns From LinqDataSource To Appear In A GridView?

Jul 25, 2010

I have a LinqDataSource and a GridView displaying a table. Columns of type xml don't show up. I'd like them to show up something like they do in Sql Server query outputs, with a link to display the clickable xml, though there may be another approach i'm not considering (maybe a styled display of the xml data, etc.). Two things i'd like to know how to do

First, get the xml converted to a string, and display it in the table. Maybe the first 30 chars.
Finally, style the xml into something useful, like a clickable link to display the full xml, or a sub-table, or a styled string.

So the following works, and displays a nice table, with edit and delete links. But Xml fields are missing. How would you go about adding support for the Xml fields?

[Code]....

View 1 Replies

ADO.NET :: How To Trigger LinqDataSource Programmatically

Mar 16, 2011

how to trigger the Select() method.

Here's the scenario: ASP.NET 3.5 C# app connecting to an MS SQL backend. I created a LINQ to SQL class called test.dbml and dragged a table called tblTest to the design surface. The table has two columns: the primary key is Email and the other column is Name. Then I dropped a LinqDataSource on the page. The LinqDataSource is not connected to a databound control. It will only being used to retrieve the name associated with a supplied email address. In the Page_Load event, I feed the Where clause:

[Code]....

However, I put a breakpoint inside the ldsAdmin_Selected event and it never hits. With an ObjectDataSource, you can use odsAdmin.Select(); to trigger the ObjectDataSource to actually run and return the info. What's the equivalent method of triggering a LinqDataSource?

View 1 Replies

Can't Set LinqDataSource InsertParameters From Code Behind

Mar 31, 2010

I have the following code that seems like it should set my insertParameter but everytime an insert happens it uses the default parameter. Do i need to do anything special to make this work?

Codebehind:

protected void SetInsertParams(object sender, LinqDataSourceInsertEventArgs e)
{
if (lbl_Personnel.Visible)
{
lds_Personnel.InsertParameters["BudgetLineTypeCode"].DefaultValue = "S";
}
else if(lbl_Operating.Visible).........

View 1 Replies

Gridview With Linqdatasource Refreshing View?

Jun 3, 2010

I've a gridview bound to linqdatasource1 and a details bound to linqdatasource2 (for searching).

When I update the data on detailsview, my gridview is not updating. I've tried handling various gridview events and databinding the gridview in code but it doesn't seem to work.

View 1 Replies

Binding LinqDataSource From Code - Behind To Gridview?

Sep 8, 2010

i have a grdidview control on the .aspx page and i am trying to connect dynamically from code behind and bind the gridview but somehow it throwing me an error... what is wrong with this code?

LinqDataSource LDS_POReport = new LinqDataSource();
LDS_POReport.ContextTypeName = "DataContextDataContext";
LDS_POReport.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(LinqDataSourcePO_Selecting);
this.gvReport.DataSource = "LDS_POReport";
//this.gvReport.DataBind();

Update:

after i update the code to this.gvReport.DataSource = LDS_POReport;

it works fine but when i try to sort i get this error:

The GridView 'gvReport' fired event Sorting which wasn't handled.

i added this but no effect.

LDS_POReport.AutoPage = true;
LDS_POReport.AutoSort = true;

View 2 Replies

C# - LinqDataSource Bound To Dynamic List?

Aug 17, 2010

Im trying to create LinqDataSource that will represent data from dynamically created String list and then use it as a datasource to my GridView.

List<string> users = RetreiveUsers();
LinqDataSource ds = new LinqDataSource();

View 1 Replies

LINQDataSource - Query Multiple Tables?

May 15, 2010

have a database and I've created a DBML Linq-to-SQL file to represent this database. I've created a new aspx page and dropped a linqdatasource and a formview control onto it. When I configure the linqdatasource it gives me the choice only to select * from one table...but I want to pull from multiple tables. e.g. I have tables like simple_person, simple_address, simple_phone, and I want to pull from all of them.

View 1 Replies

Forms Data Controls :: How To Use The Linqdatasource

Apr 15, 2010

I have written the below pages (base of question) to populate my asp.net listview control from an objectdatasource. To allow for easier CRUD commands and to make my application more efficient I want to replace this objectdatasource with a linqdatasource but when I attempt this I receive a binding error which stops my ItemDataBound event firing? I'm basically replacing my objectdatasource with the below linqdatasource...

[Code]....

[Code]....

Am I placing my query within the wrong event? Why does my ItemDataBound event not fire?

PAGES:

[Code]....

[Code]....

View 3 Replies

C# - LINQDATASOURCE Do Not Commit To Database Straight Away?

Nov 6, 2010

I'm using a LinqDataSource with a RadGrid. When I Add a new Grid item and click insert the values are immediately saved to the database.Is there a way where they can be actually not put in the database until I give the command?

View 1 Replies

C# - LinqDataSource - Filtering And Binding To Gridview?

Jul 28, 2010

the problem is not solved the way i wanted but i go ahead give the credit to : ƁukaszW.pl for his time and effort.

i am using gridview control and a linqdatasource and its all working fine and i have added the functionlity of searchingBySubject and i added WhereParameters and than binding my gridview (see the code below) but somehow its not returning any rows and i see i have number of rows based on what i am searching.

protected void btnSearch_Click(object sender, EventArgs e)
{
this.LinqDataSource1.WhereParameters["Subject"].DefaultValue = this.txtSubject.Text;

[ode]....

View 2 Replies

LinqDataSource - Filtering For Null Values?

Aug 19, 2010

I am writing an ASP.Net web application. I have listview, it's datasource is a LinqDataSource. In my database, I have a staff table and I am trying filter for records by their team using a dropdownlist. This works fine, until I select "All" in the dropdownlist. It returns all staff except for the ones where the teamID is null. How can I return the records where teamID is null?

This is my code:

<asp:ListView ID="ListView1" runat="server" DataSourceID="ldsStaff" DataKeyNames="staffID">
<LayoutTemplate>
<table>
<tr>
<th>Name</th>
<th>Team</th>
</tr>
<tr>
<td> </td>
<td><asp:DropDownList ID="ddlTeamFilter" runat="server" DataSourceID="ldsTeams" DataTextField="Team" DataValueField="TeamID" AppendDataBoundItems="true" AutoPostBack="true">

[Code]....

View 1 Replies

Implement Gridview Search Using LinqDataSource

Oct 21, 2010

I have two tables:

Orders
OrderProducts - An order can have 1 to many orderProducts records associated with it.

What I am trying to do (unsuccessfully) is to implement a GridView search using a LinqDataSource wherein the search returns Order results where any of the OrderProduct.Manufacturer columns contain a search query. I was hoping the following would work, however it seems lambda expressions do not work within a Where clause of a LinqDataSource (in VB):

<asp:LinqDataSource ID="dsOrders" runat="server" ContextTypeName="myDataContext" TableName="orders"
Where="orderProducts.Any(Function(op) op.Manufacturer.Contains(@searchTerm))">
<WhereParameters>
<asp:ControlParameter Name="searchTerm" ControlID="txtSearchTerm" DefaultValue="" />
</WhereParameters>
</asp:LinqDataSource>

In C# it would look like:

<asp:LinqDataSource ID="dsOrders" runat="server" ContextTypeName="myDataContext" TableName="orders"
Where="orderProducts.Any(op => op.Manufacturer.Contains(@searchTerm))">
<WhereParameters>
<asp:ControlParameter Name="searchTerm" ControlID="txtSearchTerm" DefaultValue="" />
</WhereParameters>
</asp:LinqDataSource>

The error I am getting is:

No property or field 'op' exists in type 'orderProduct' Any clues as to how to get this working within the LinqDataSource definition, or will I have to handle and set up a custom OnSelecting event?

View 1 Replies

Error Message On Using LinqDataSource In Webforms

Dec 24, 2010

I am binding a GridView with LinqDataSource with AutoDelete functionality enabled. GridView is bound to the Products Table. I have a Products Table and a Category Table with an association on CategoryID. If I try to delete a Category that is referred in the Products Table I cannot do that. Its is totally acceptable, but I want the end user to be notified with some error message. Where to catch this error message?

View 2 Replies

C# - TemplateField Not Updating In GridView Using LINQDataSource?

Sep 2, 2010

Im using a LINQDataSource to populate a GridView of Universities.

Each University has an associated State, which is in another table and associated by a foreign key (StateID).

I have a TemplateField in the GridView so that when you view it normally it displays the StateName which comes from the State table and when you edit it shows a DDL populated with everything from the State table.

[Code]....

If I debug, inside of RowUpdating, GridViewUpdateEventArgs.NewValues doesnt even have a key for State.

Question: How do I let my gridview know I want it to update this column? All the BoundFields just seem to work...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved