Avoid Loading A LINQ To SQL Object Twice When Editing It On A Website

Apr 9, 2010

I know you are all tired of this Linq-to-Sql questions, but I'm barely starting to use it (never used an ORM before) and I've already find some "ugly" things. I'm pretty used to ASP.NET Webforms old school developing, but I want to leave that behind and learn the new stuff (I've just started to read a ASP.NET MVC book and a .NET 3.5/4.0 one). So here's is one thing I didn't like and I couldn't find a good alternative to it.

In most examples of editing a LINQ object I've seen the object is loaded (hitting the db) at first to fill the current values on the form page. Then, the user modify some fields and when the "Save" button is clicked, the object is loaded for second time and then updated. Here's a simplified example of ScottGu NerdDinner site.

//
// GET: /Dinners/Edit/5
[Authorize]
public ActionResult Edit(int id) {
Dinner dinner = dinnerRepository.GetDinner(id);
return View(new DinnerFormViewModel(dinner));
}
//
// POST: /Dinners/Edit/5
[AcceptVerbs(HttpVerbs.Post), Authorize]
public ActionResult Edit(int id, FormCollection collection) {
Dinner dinner = dinnerRepository.GetDinner(id);
UpdateModel(dinner);
dinnerRepository.Save();
return RedirectToAction("Details", new { id=dinner.DinnerID });
}

As you can see the dinner object is loaded two times for every modification. Unless I'm missing something about LINQ to SQL caching the last queried objects or something like that I don't like getting it twice when it should be retrieved only one time, modified and then comitted back to the database. So again, am I really missing something? Or is it really hitting the database twice (in the example above it won't harm, but there could be cases that getting an object or set of objects could be heavy stuff).

View 3 Replies


Similar Messages:

Data Controls :: GridView Row Editing DropDownList / Object Reference Not Set To Instance Of Object

Dec 22, 2013

 I am trying to implement the code URL...I have a database table with Integer type.Here is the running code line: Code in GridView:

<asp:TemplateField HeaderText="RegionNavn">
<ItemTemplate>
<%# Eval("RegionNavn")%>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblRegionNavn" runat="server" Text='<%# Eval("RegionNavn")%>' Visible = "false"></asp:Label>

[code]...

On Edit Click, the DropDownList in the GridView brings the previously selected value.On Update Click, the error is: "System.FormatException: Input string was not in a correct format."

dCmd.Parameters.Add("@KystverketRegionID", SqlDbType.Int).Value = int.Parse(ddKystverketRegionID.SelectedValue);
 
When I use the following code:

ddlRegionNavn.DataTextField = "RegionNavn";
ddlRegionNavn.DataValueField = "RegionID"; // from RegionNavn to RegionID

On Edit Click, the DropDownList values in the GridView is not firing and the following error shows.Object reference not set to an instance of an object. How to implement the code when having a value of type Int ?

View 1 Replies

Avoid Loading Time While Using Repeater

Jul 26, 2010

I am using .net 3.5 framework and i am using repeater control in my application.I am using link button to display the records.Displaying 9 records in a page.Show all button is there.When i click on show all button(Result of 250 records) then the page is loading and hanging for some time anf then it is displaying the all records.I know the time taken between the server and the browser.But i need to avoid the hanging of the page and the loading time should be reduced.How to solve this issue.If the page contains 9 products then it is loaded quickly.But if it contains lot of images then it's hanged. some of my friends told to use the jquery but i have noo idea regarding jquery so can anyone give an solution for this.Till it's breaking my head.

View 2 Replies

Web Forms :: Avoid Loading Time While Switching Over From One Menu Item (tab) To Another?

Feb 24, 2011

I have used the following controls in my web page.

1.Menu
2.Multi view
3.view
4.Gridview

But my problem is...whenever i clicks on the menu item it loads particular content individually. I mean if i click on menuitem1 it takes some time to load Gridview1 , after if when i click on menuitem2 again it takes some time to load Gridview2. Is there is any way to load all the menu items content during first time of page load. So that we can avoid loading time while switching over from one menu item(tab) to another.I have used the following code

[Code]....

View 1 Replies

MVC :: Avoid Loading Images When Using Caching And Javascript Image Preloader In An Mvc Application?

Jun 18, 2010

i have implemented an image preloader using javascript inside my mvc 2 web app, in order to display an animated "loading" image .gif while sequentially displaying page images.I have also implemented caching using a cache profile for the controller action that displays the specific page ([OutputCache(CacheProfile = "LongCache")]).The problem is that the image preloader javascript is called when caching is applied. I was wondering whether i could, somehow, use the image preloader code only when the page gets refreshed and not when the cached version is rendered.

View 2 Replies

DataSource Controls :: Editing Data With Linq To Entities

May 21, 2010

I'm trying to update data with the EF I can't seem to get the EntityKey when I debug and hit this line befor I save changes _entities.ApplyPropertyChanges entityToEdit.EntityKey .EntitySetName, blogEntryToEdit); The EntityKey is null dose anyone have any idea how this key is set can't SaveChanges() without it _entities.ApplyPropertyChanges(entityToEdit.EntityKey .EntitySetName, blogEntryToEdit);

View 6 Replies

MVC 2 - Using LINQ And Sending A Linq Object To The View And Trying To Show It In A Textbox

Mar 11, 2011

I am using LINQ and sending a linq object to the view and trying to show it in a textbox like this

<%=Html.TextBox("petname",Model.PetName) %>

But I am getting error, how can I show (PetRecord.PetName) which is my linq entity

View 1 Replies

C# - Avoid Double Control Search In LINQ Query?

Jun 23, 2010

I have a Dictionary<string, bool> where key - control's ID and value - it's visible status to set:

var dic = new Dictionary<string, bool>
{
{ "rowFoo", true},
{ "rowBar", false },
...
};

Some of controls can be null, i.e. dic.ToDictionary(k => this.FindControl(k), v => v) will not work because key can't be null. I can do next:

dic
.Where(p => this.FindControl(p.Key) != null)
.ForEach(p => this.FindControl(p.Key).Visible = p.Value); // my own extension method

but this will call FindControl() twice for each key. How to avoid double search and select only those keys for which appropriate control exists? Something like:

var c= FindControl(p.Key);
if (c!= null)
return c;
but using LINQ.

View 4 Replies

DataSource Controls :: Linq To SQL Set Linq Object Propertychanged?

Mar 12, 2010

I am writing a plugin to help with a current ERP system we have that I am not allowed to modify the data structure at all. The table I am dealing with has over 100 columns and I am wanting to set my linq object propertychanged event and submitchanges or do I really have list out each property and set it equal to the new one?Below is an example of what I am trying to do:

[Code]....

View 4 Replies

DataSource Controls :: LINQ To DataSet And LINQ To Object

Mar 9, 2010

txtLastName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Last_Name.ToString();

Like that I have large number of controls on my form. I have dought, if I assigned like this, db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Last_Name.ToString(); to every control, then I have set of controls like,

ddlSalutation.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Salutation.ToString();
txtLastName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Last_Name.ToString();
txtFirstName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).First_Name.ToString();
txtMI.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Middle_Initial.ToString();
txtAddress.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Home_Address.ToString();
txtCity.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).City.ToString();
ddlState.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).State.ToString();
txtZip.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Zip_Code.ToString();
txtSSNo.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ssn.ToString();
txtMRNo.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Mr_No.ToString();
txtDOB.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Birth_Date.ToString();
RBGender.SelectedItem.Value = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Gender.ToString();
RBMaritalStatus.SelectedItem.Value = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Marital_Status.ToString();
txtHomePhone.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Home_Phone.ToString();
txtWorkPhone.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).WorkPhone.ToString();
txtCellPhone.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).CellPhone.ToString();
ddlSuffix.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Suffix.ToString();
txtReligion.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Religion.ToString();
txtEmail.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Email.ToString();
txtSSOName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ssn.ToString();
txtPatientKin.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Patient_Kin.ToString();
txtRelationWithPatient.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Kin_Relation.ToString();
txtPhoneNo.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Kin_Phone.ToString();
ddlPreferredPharmacy.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Id_Pharmacy.ToString();
txtEmergencyContactName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Emergency_Contact_Name.ToString();
txtEmergencyContactNumber.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Emergency_Contact_Phone.ToString();
txtRelation.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Kin_Relation.ToString();
txtRace.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Race.ToString();
ddlHowDidPatientFindUs.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).How_Found.ToString();
txtEmployerName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Employer_Name.ToString();
txtEmployerOccupation.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Employer_Occupation.ToString();
txtEmployerPhone.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Employer_Cell_Phone.ToString();
txtEmployerAddress.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Employer_Address.ToString();
txtEmployerCity.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Employer_City.ToString();
ddlEmployerState.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Employer_State.ToString();
txtEmployerZip.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Employer_Zip.ToString();
txtRecordsReleasedTo.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Records_Released_To.ToString();
txtOtherInfo.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Other_Info.ToString();
txtPopupNote.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Popup_e.ToString();
ddlPPlanName.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Insurance_Name.ToString();
txtPGroupNo.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Group_No.ToString();
txtPIDNo.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Id_No.ToString();
txtPPhone.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Plan_Phone.ToString();
txtPVerifiedWith.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Verified_With.ToString();
txtPVerifiedPhone.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Verified_Phone.ToString();
txtPEffectiveDate.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Effective_Date.ToString();
txtPExtDate.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Ext_Date.ToString();
if (db.usp_ATI_FetchPatientDetails(iPatientID).Count() > 0)
{
txtPGLastName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_Name.ToString();
txtPGFirstName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_Name.ToString();
txtPGMI.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_MI.ToString();
txtPGBirthGDate.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_Dob.ToString();
txtPGAddress.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_Address.ToString();
txtPGCity.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_City.ToString();
ddlPGState.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_State.ToString();
txtPGZip.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_Zip.ToString();
txtPGEmployerFirstName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Grn_Emp_Fname.ToString();
txtPGEmployerLastName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Grn_Emp_Lname.ToString();
txtPGEmployerPhone.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Grn_Emp_Phone.ToString();
txtPGEmployerOccupation.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Grn_Emp_Occupation.ToString();
txtPGEmployerAddress.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Grn_Emp_Address.ToString();
txtPGEmployerCity.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Grn_Emp_City.ToString();
ddlPGState.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Grn_Emp_State.ToString();
txtPGEmployerZip.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Grn_Emp_Zip.ToString();
ddlPGPatientRelationshipToGuarantor.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Grn_Rel_With_Pat.ToString();
txtPGOtherInsuranceNotes.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Other_Notes.ToString();
txtPGAuthorization.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_Authorization.ToString();
txtPGAob.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(0).Ins_AOB.ToString();
}
if (db.usp_ATI_FetchPatientDetails(iPatientID).Count() > 1)
{
txtSGLastName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_Name.ToString();
txtSGFirstName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_Name.ToString();
txtSGMI.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_MI.ToString();
txtSGBirthGDate.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_Dob.ToString();
txtSGAddress.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_Address.ToString();
txtSGCity.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_City.ToString();
ddlSGState.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_State.ToString();
txtSGZip.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_Zip.ToString();
txtSGEmployerFirstName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Grn_Emp_Fname.ToString();
txtSGEmployerLastName.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Grn_Emp_Lname.ToString();
txtSGEmployerPhone.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Grn_Emp_Phone.ToString();
txtSGEmployerOccupation.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Grn_Emp_Occupation.ToString();
txtSGEmployerAddress.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Grn_Emp_Address.ToString();
txtSGEmployerCity.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Grn_Emp_City.ToString();
ddlSGState.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Grn_Emp_State.ToString();
txtSGEmployerZip.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Grn_Emp_Zip.ToString();
ddlSGPatientRelationshipToGuarantor.SelectedItem.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Grn_Rel_With_Pat.ToString();
txtSGOtherInsuranceNotes.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Other_Notes.ToString();
txtSGAuthorization.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_Authorization.ToString();
txtSGAob.Text = db.usp_ATI_FetchPatientDetails(iPatientID).ElementAt(1).Ins_AOB.ToString();
}

My question is that, for each control the Stored Procedure called or not? If it is yes then it is time consuming and I need to use LINQ to DataSet or LINQ to Object rather than to call SP for each control. What is difference between LINQ to DataSet and LINQ to Object?

View 5 Replies

Can Handle Null Value In Linq / Object Reference Not Set To An Instance Of An Object

May 10, 2010

[code]....

this code give that solution.but if any one of the field have null(example:r.urrQuickLinkRights contain the NULL) then only it will throw error like Object reference not set to an instance of an object.

View 2 Replies

Visual Studio :: Running Website Windows 7 Professional 64 Bit / On Loading Up A Website Project Getting Error?

Mar 6, 2010

I have a new development machine running windows 7 professional 64 bit. On loading up a website project Im getting this error

'The Web Application Project 'websitename' is configured to use IIS. To access local IIS websites, you must install IIS components:

IIS 6 Metabase and IIS 6 Configuration Compatibilty

ASP.net

Windows Authentication

In addition you must run Visual Studio in the context of an administrator account

As far as Im aware, I am an administrator of my own pc and I have the .net framework installed.

View 4 Replies

Web Forms :: How To Avoid Null Object Reference Page Load

Nov 18, 2010

I have a user control with GridView. GridView template has label that suppose to get custom object value Name.

aspx:

<asp:Label ID="lblImage" runat="server" Text='<%# MyData.Name%>' />

cs:

public MyObject MyData;

During page loading MyData object is null, so I'm getting exception: "Object reference not set to an instance of an object.".

How to avoid the error?

View 5 Replies

JQuery :: How To Avoid Page Refreshing / How To Use Ajax On Page Loading

Nov 29, 2010

I want to avoid page refereshing or loding with the of jquery ajax. Here i am attatch my asp page code.

[Code]....

In this page I am trying to use jquery ajax on page loding but it does not give response .

View 20 Replies

C# - Linq To SQL Where In Clause Causes Object Not Set To Instance Of Object

Jul 1, 2010

I have two tables, subscriptions and topics. Each subscription is related to a specific TopicID (PK for topics table). The first query works fine and retrieves the topicID's of all videos that were uploaded today. The problem occurs when I try and then use the results of query1 as a where-in clause for query 2. I keep receiving object reference not set to instance of an object.

Query 1 IQueryable<int> topics = (from t in dataLayer.Videos
where SqlMethods.DateDiffDay(t.DateCreated, DateTime.Today) == 0
select t.TopicID).Distinct(); [code]....

I have looked at some samples around the net and they all seem to be identical to mine.

View 1 Replies

Editing Aspx Website Template With C#?

Jul 2, 2010

I have a template for a website, and I want to edit the aspx files with C#, thats means that I want each of the aspx files have a code behind file, which is .aspx.cs file for each .aspx exist file.

I opened a new ASP.NET AJAX Website Template and copied the .aspx files, the webconfig and the css to the new website I created.

when I add control and double-click on it in order to create a .aspx.cs file for this page,
it brings me to the source code.

I've added this line as the first line of my aspx file in order to create a .aspx.cs file:

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Login.aspx.cs" Inherits="Login" %>

but still it dont let me create an aspx.cs file.

View 1 Replies

Web Forms :: How To Avoid Session Timeout In Website

Oct 25, 2013

In my website, the session is expired after 5 minutes. I need to extend the seesion state to minimum 4 hours. Currently, in web.config file I used the following code.

<sessionstate cookieless="false" timeout="1440"></sessionstate>

But its expired after just 5 minutes.

View 1 Replies

Common Approach While Saving And Editing Images In A Website?

Sep 8, 2010

I am building a website using asp.net and this website will host users images and will give them options to edit these images by resizing, cropping, watermarking,.... am thinking of 2 ways to save images and want someone to recommend one or advice me with something different better.1- The user will upload his images, i will put them in a folder called "original" then the user will edit these image, i will put the edited images in a folder called "edited" also will have another folder called "thumb" will contain thumbnails from these images for previewing on the website.

View 1 Replies

Configuration :: Editing Web.config Of Live Website (application)?

May 11, 2010

What will happen if we edit the web.config file of a live application ?

What steps should be followed to edit it on live environment?

View 5 Replies

ADO.NET :: Linq To SQL Lazy Loading, Immediate Execution, ToArray()?

Jul 28, 2010

I am developing a website that has more and more LINQ queries. I have been keeping down the download size, optimizing the images, js, css and using HTTP Compression. I notice however, that now that I am using more LINQ queries and more complex queries, join and group joining queries, the 'waiting' time that the browser is doing is going up. The KB size of the page isn't any greater, but the page ultimately takes longer to load.

I have been reading up on LINQ and the behind the scenes of how it works. I have found that I need to use DataLoadOptions for the queries that join/group join to reduce the round trips to the database. I haven't had a chance to work on this yet, so if anyone has any great resources on this or tips, I'd appreciate it.

My main question about LINQ to SQL in this post is, if I have a bunch of queries throughout my site, in the masterpage, and the page itself, if I do not put .ToArray() at the end of the query, does that speed it up? If I leave ToArray() off of all the queries, do they then execute all at once when the page is loading instead of each time the page gets to that specific line to read and execute it?

I may be asking a dumb question, since I don't know a whole lot about the behind the scenes of LINQ yet, or the compiling of the page. I am using VWD 2010, so it does not have the SQL Profiler for me to test what I am asking.

View 2 Replies

C# - Loading Xml Into A Xdoc, And Then Initializing An Object?

Mar 9, 2010

public class Template
public string Title {get;set;}
public string Body {get;set;}
xml that is stored in /files/test.xml in a web application (at the root):
[code]...

View 3 Replies

ADO.NET :: EF4 / Linq Eager Loading With Include Fails To Populate All Results?

Aug 25, 2010

I'm trying out EF4 as part of a .Net 4.0 WCF service. The aim of the service is to return document data as an array of entity objects to any of our ASP.Net apps. The apps are still in .Net 2.0. Due to the nature of the solution I've disabled LazyLoading at context level. I started with this:

[Code]....

Everything works ok, I receive the correct number of populated objects. However when I add an Include into my query to allow us to pickup fields from a related table that has a defined navigation only the first record is returned fully populated to a calling application:

[Code]....

The array is the correct size but all elements after the first are blank, default placeholders. Its like using the Include has reverted to LazyLoading and I can't seem to kick it into line.

View 3 Replies

Loading Uploaded Xml File Into XmlDocument Object (ASP.Net, MVC, C#)

Jul 27, 2010

I'm getting back into coding after a seven year absence. Loving it, but everything is taking me so long!Anyway, I'm trying to upload a file from the browser and then read it into an XmlDocument object on the server. Originally I cracked this by saving the file to disk, reading it into the XmlDocument object and then deleting the file. The only problem was that the delete action was trying to take place before the XmlDocument.Load action had completed

View 2 Replies

Website Not Loading

Jul 17, 2010

why my website is not loading ?https://jamboinc.com/Default.aspx

View 4 Replies

Web Forms :: CDO.Message Object Error Loading Type Library / DLL

Jan 8, 2010

It has a part where it sends new users their first password in email.. and yes I'm getting that annoying cannot access CDO.Message object error traced back to the "Error loading type library/DLL" message. but I remember that it used to work fine with my old computer I started the development on.

1. It isn't a permission error.. like most cases (tried granting admin access to the ASPNET user)

2. I have the required dll files registered (checked them several times and even reinstalled them a few times)

3. Tried putting only that piece of code in a new application to be able to experiment.. Started commenting out blocks of code until it finally "worked" (I didn't get the error). So it seems like I only get the error if I add a mail field (which is bad since I need those for authentication..)

View 5 Replies







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