Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A
dotnetinter

What is eager loading in c# ( C# eager loading interview questions with answers)?

Eager loading is opposite to Lazy loading. If you are new to lazy loading please read c# lazy loading interview question with answers.

In eager loading we load the objects in one go even if the objects are needed or not by the client. For example look at the below c# code. The Customer class has order objects. So the order object is loaded in the constructor, even if the order object is required or not by the UI clients.

public class Customer
{
private List _Orders= null;


public Customer()
{
         _CustomerName = "Shiv";
         _Orders = LoadOrders(); // Loads the address object even though //not needed
       
}
 
private List LoadOrders()
{
         List temp = new List();
         Order o = new Order();
         o.OrderNumber = "ord1001";
         temp.Add(o);
         o = new Order();
         o.OrderNumber = "ord1002";
         temp.Add(o);
         return temp;
}

}

Thanks to questpond.com to provide this c# interview questions with answers.
Tags: .net eager loading interview questions, c# eager loading interview questions, c# lazy loading interview questions, csharp interview questions, eager vs early loading in c#, information technology questions, programming iterview questions, what is eager loading in .net
Subscribe

  • Stored Procedure in SQL Server.

    Stored Procedure in SQL Server Stored Procedure is collection of Sql code that can be saved under a name in SSMS(Sql Server Management Studio).…

  • SQL Server: - Extended Events

    What is Extended Events? SQL Server Extended Events helps the database administrator to collect the information necessary to identify performance…

  • SQL Server - Stored Procedure

    In this article we will understand what is the use and why do we need Stored Procedure. What is Stored Procedures? A stored Procedure is a set of…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments