|
indian143 wrote: I dont know how to see that, but he told me.
Who told you there were using too much memory? How did they know? Did you ask? More memory compared to what? Is it the query or the data that is taking up too much memory?
Linq does use more memory than traditional ADO.NET but there isn't much you can do about it and the trade-off is more beneficial in ease of use, maintenance, extensibility and in some cases performance.
from a in quarterlyUpdateSubscription
join b in parallelDataContext.teBinaryDatas on
a.DeltaReportBinaryDataID equals b.BinaryDataID
select b.Data
Since we have no idea what data is behind this an accurate assessment can't be made. However, if there are large sets involved here it will of course use more memory to store and perform the query and join. If you can reduce the size of the set it may help.
I know the language. I've read a book. - _Madmatt
modified on Friday, July 1, 2011 12:19 AM
|
|
|
|
|
Hi,
Thanks for the reply, its not compared to any thing. But its taking 1 GB memory my architect said. And one more thing it could be data only that is taking more memory.
Now, I will put the question in different way
Can I tune my Linq and Lambda query to select less data and use less memory so that I can improve my functions performance? Below is the code.
Thanks for any kind of help, thanks in advance.
public string GetQuarterlyUpdateTUCDataXml( int quarterlyUpdateJobId, int quarterlyUpdateSubscriptionId)
{
string strQuarterlyUpdateDeltaReport = null;
var quarterlyUpdateSubscription = parallelDataContext.teQUTUDatas.Where(c => c.QuarterlyUpdateJobID ==
quarterlyUpdateJobId && c.QuarterlyUpdateSubscriptionID == quarterlyUpdateSubscriptionId).ToList();
if ((quarterlyUpdateSubscription != null) &&
(quarterlyUpdateSubscription.Count > 0))
{
byte[] encryptedBytes = (from a in quarterlyUpdateSubscription
join
b in parallelDataContext.teBinaryDatas on
a.DeltaReportBinaryDataID equals b.BinaryDataID
select b.Data).FirstOrDefault().ToArray();
strQuarterlyUpdateDeltaReport = (encryptedBytes != null) ?
objCommon.GetDecryptedReportString(encryptedBytes) : "";
}
return strQuarterlyUpdateDeltaReport;
}
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
There was no need to post the code again.
As I stated, there may be a way to reduce the size but I have no idea of the data structure or your requirements. Maybe your architect would be the one to ask
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
For a method returning a single string, this is rather wasteful: you bring in a list of items in memory (with a call of ToList() ), then run a join, but then you throw away all but the first item of the result!
You don't need a list of teQUTUData objects in memory: all you use is their DeltaReportBinaryDataID column, so select only that column in your first LINQ query (add .Select(a => a.DeltaReportBinaryDataID) to the first query).
Next, you don't need a join in your second query: it's an in-list lookup. Rewrite your query to run a select from parallelDataContext.teBinaryDatas, where quarterlyUpdateSubscription contains b.BinaryDataID.
This should do the trick. Good luck!
|
|
|
|
|
Hi,
Your post has helped me greatly. I really appreciate your help. I am really greatfull for this help. You not only helped me in solving the problem but also helped me in understanding the usage of select in the linq. Thats where real puzzle there I think so.
Once select is understood then Linqs become easy I think.
In all the ways this help is really appreciable. Thanks a lot again.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
|
Download LINQPad a free tool that will allows you to test your queries.
This tool is really helpfull to optimize your query because it will display the time it takes to executed code. Also, it is possible to see the generated SQL. Anytime the SQL seems way too complex or the number of queries is large, you should try to see it it can be improved.
http://www.linqpad.net/[^]
Also since the tool nicely display the result, it is possible to validate visually that your queries make senses. For example if hte number of returned rows is bigger than expected, a WHERE clause might be missing.
This tool is a must have. It may it easy to compare alternative queries. Also a lot of sample come with the tool and show different thing like how to do grouping, how to test NULL value in a database and more.
Sometime a simple difference like exchanging SingleOrDefault() with FirstOrDefault() can make a huge difference in the query even though the result would be the same (apart that in one case it would have been check that a single item exists.
Also it will help to spot iterative requests. That is when a query would cause a first request then repeat another sub-request for each element. Sometimes, it might be preferable to explicitly make 2 simpler requests that LINQ to SQL would be able to translate in 1 SQL request each instead of a big request that would result in mlutiple request.
Philippe Mori
|
|
|
|
|
LINQ queries are executed only when results are required to be used in the code.
ToList() and
ToArray() force the queries to execute since the results are to be stored in the respective list and array. If the query is large enough, then it sure will consume huge memory. As dasblinkenlight already suggested, rewrite your query to select only the rows and columns that you actually require instead of loading the entire table and reading the required row/column.
|
|
|
|
|
Hi,
I was using LinqToExcel.dll file before in my win 32 bit machine and was working fine. Now when i try my project(asp.net) in win 64 bit, it gave error because of this LinqToExcel.dll file. Is there any equivalent file for LinqToExcel.dll file for win64 bit? Does anybody have any ideas or suggestions??
suchita
|
|
|
|
|
SayamiSuchi wrote: it gave error
How many times do we hear this? And the the response is the same.
What error!?! If you want help you must provide sufficient details.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
in my local machine, since its 32 bit, i can't see the error. But because of that file, it is not running in 64 bit machine..
suchita
|
|
|
|
|
Post here your exception message.
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
If you can't see an error then how can you be sure it is this file? What debugging or diagnostics steps have you taken to isolate this file as the problem?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
I am using visual studio 2010.
and i have html file which can be readed.
so i changed html file to asp(only change file extension).
But after that, i can't read asp.
Web page only show "This type of page is not served."
How can i read asp file?
(I am using windows7 64bit ans visual studio 2010).
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
The problem isn't with VS, it can "read" many types of files. To view an asp file in the browser it must be hosted in IIS, the development web server with VS won't work.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Tanks for your reply.
Have a nice day!
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
5 - correct answer.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hi,
I am working on an existing page1.aspx page
It has <asp:UpdatePanel with dropdownList controls inside it.
In this page there is also a usercontrol which has a hyperlink which allows
the user to be redirected to page2.aspx.
i.e. XXXX.NavigateUrl = "Page2.aspx?somevaluesXXX
On Page2.aspx, there is a backbutton which should take you to the previous page i.e.
page1.aspx in this case.
How do I go back to the previous page i.e. page1.aspx with the optioins I selected in my dropdowns in page1.aspx?
At present I have this javascript on the click of goback button
but it does not work.
BtnBack.Attributes.Item("onclick") = "history.back(1);return false"
What needs to be done please?
Thanks
|
|
|
|
|
You need to persist the settings in some fashion, either by passing them via the query string or storing in session state, so the form can be reset using these values.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I want to fill gridview textbox by selecting data from gridview Dropdownlist
|
|
|
|
|
try like this
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList gridDropDownList = (DropDownList)sender;
GridViewRow gridRow = (GridViewRow)gridDropDownList.NamingContainer;
int selectedIndex = gridRow.DataItemIndex;
TextBox textBox = (TextBox)GridView1.Rows[selectedIndex].FindControl("yourTextBoxID");
string selected = gridDropDownList.SelectedValue;
if (textBox != null)
{
textBox.Text = selected;
}
}
My Mind is the Devil's Workshop.
|
|
|
|
|
Dear raju melveetilpurayil,
Thanks for your reply. It's useful.
|
|
|
|
|
Hi,
I suggest to you a javascript client solution:
add this javascript function somewhere in your project
function selectChoice(ddl, textboxID) {
var chosenoption = ddl.options[ddl.selectedIndex];
if (chosenoption.value != 'nothing') {
document.getElementById(textboxID).value = chosenoption.value;
}
}
add onrowdatabound event for your grid with this code:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlChoice = e.Row.FindControl("ddlChoice") as DropDownList;
TextBox txtSelectedValue = e.Row.FindControl("txtSelectedValue") as TextBox;
string jScript = "selectChoice(this, '{0}');";
ddlChoice.Attributes.Add("onchange", string.Format(jScript, txtSelectedValue.ClientID));
}
}
____________________
Web Programmer
http://glucolo.wordpress.com
modified on Monday, July 4, 2011 6:10 AM
|
|
|
|
|
HI,
My excuse of the subject line if wrong.
I need you peoples expert advice on one of my project.
Scenario:
I have ASP.NET 2.0 project which is n-Tier project. In one or many tier (project in same solution as my website) I am using web services and these project are added as references. So the dll comes in my BIN folder of website.
I have two different web application and web services related to each one of them i.e. one for my testing and another for my live. So when I want deploy my website on testing, I compile my code and deploy on testing web app and if testing is success then I copy my compiled code from testing to live web app.
Problem:
Now the problem when I change any thing in my project (i.e tier), I need to change web references for that project from development environment, compile it and deploy on testing. If testing is ok then I have to again change the web references for the web service, compile it again and deploy on live.
Needed Solution:
So my question is; is there any other way to just change in config file and without compile again for live I can move from testing to live.
Note: Though I am using ASP.NET 2.0 version my code gets compiled in backward compatibility i.e. 1.1.
Looking for to hear from experts soon..
Regards,
Smart Boy
Mumbai,
(INDIA)
|
|
|
|