ORM - Linq Interview questions - International Days

International Days

Internationally important Days

Breaking

Home Top Ad

Post Top Ad

Monday, 11 September 2017

ORM - Linq Interview questions

Q) What is ORM (ORM Interview questions -1)

ORM (Object Relational Mapping ) is processing data from a relational database and create it into a more easily operational to our coding. ORM is nothing but a path way to map a relational database to logical objects in your object oriented programming language .

Q)What are the advantages and disadvantages of ORM (ORM Interview questions -2)

Advantages

  • Reduce line of codes in creating a business process
  • Provides persistence to the object
  • Code Reuse
  • Application maintainability :- We could easily switch from one database to another.
Disadvantages

  • Performance
Q)What are the ORM packages available for .Net (ORM Interview questions -3)

  • Base One Foundation Component Library
  • Base One Foundation Component Library
  • DatabaseObjects .NET
  • DataObjects.NET
  • Dapper
  • ECO
  • Entity Framework, included in .NET Framework 3.5 SP1 and above
  • EntitySpaces
  • iBATIS
  • NHibernate
  • Persistor.NET
  • Neo
  • LINQ to SQL
  • nHydrate
  • XPO
  • Quick Objects
  • SubSonic
  • SqlMappe
  • nHydrate
  • MapLess

Q)Challenges in implementing ORM? (ORM Interview questions -4)
   
   We need to spend time for researching on which ORM package allow us to create highest quality SQL queries . In short we need to select the package which is giving high performance SQL query. If all our requirement didn't meet with the existing packages out there then we have to create one Object Relational Mapping as by our own.

Q) What is LINQ stands for ? (LINQ Interview question-1)

   LINQ : is Languange integrated query .
In order to reduce complexity of accessing and integrating information from two most common sources (Relational Database and XML ), .Net introduces LINQ which allow us to get information from by creating general purpose query from relational database ,XML data and all sources of Information including the data in memory.

LINQ is collection of standard query operators that provides the query facilities into .NET framework language like C# , VB.NET

Q) Advantages of Linq ? (LINQ Interview question-2)

   For querying using Linq we does not need any SQL,MYSQL,Xquey skills. All you need to know how to write Linq query that is Common syntax for querying on type of database

LINQ binds relational between Object oriented approach , that is it reduces the gap between them.
LINQ is strongly typed
It catches error at compile time so querying is more error free
It include insistence ans debugging support

Q) In which version LINQ is introduced (LINQ Interview question-3)
    
       .Net 3.5


Q)What is Lambda Expression ? (LINQ Interview question-5)

   A lambda expression is an anonymous function and that you can use it to create delegates or expression tree types. Using Lambda expression one can create local functions that can be passed as arguments or returned as value of function calls. Lambda expressions are usually writes for creating LINQ queries.


Q)What is Query Expression ? (LINQ Interview question-6)

  Query is a set of instructions that describes what data to be retrieve from a given data source .
A query expression is a query expressed in query syntax .It is a first class language construct can be used in which a c# expression is valid



Q)Difference between Stored procedure and LINQ ? (LINQ Interview question-7)
  • LINQ has performace issues in case of complex queries , but there will be not much performance issues in simple CURD queries .
  • One LINQ query can be used in more than one data bases but Stored procedure is binded to only that Database
  • While making any change in LINQ query you need to rebuild the application and has to update the dlls but in case of sp you need to change only the particular stored procedure
  • In case of security , the database table is exposed directly to the application . But in Stored procedures , the result set is exposed to the application not the tables
  • Deployment is more easy than the stored procedures , In LINQ everything is bind and wrapped with in the DLL itself. But in stored procedures , you need to separately manage the updated query also should update the production environment separately.


Q)Three main components of LINQ ? (LINQ Interview question-8)



   Standard query operators
   Language Extensions
   LINQ Providers


Q)Where clause and Let clause ? (LINQ Interview question-9)


  Using let clause we can create a new variable in a query . We can manipulate it before we are getting result. Let clause allows us to create variable in side the LINQ query
Where as the 'where' clasuses is used to filter data with certain condition .
Ref : http://www.c-sharpcorner.com/UploadFile/ff2f08/let-operator-in-linq/


Q)Why Select clause comes after from clause in LINQ ? (LINQ Interview question-10)

  LINQ is used with C# or other Language which will be needed to declare the variables first. From clause in LINQ does defines the rage of different conditions for select records . This is the reason why select clause must comes after from clause .


Q)How to remove from List using Lambda expression ? (LINQ Interview question-11)
We can remove form List by using RemoveAll,Remove and RemoveAt
  • RemoveAll -> Removes all records that succeed certain criteria .
  • Remove -> Removes single record by passing object itself.
  • ReoveAt ->Remove single record based on index.
Q)How can we select list of objects inside another list of objects ? (LINQ Interview question-12)

We can use 'SelectMany' extension Method .

class ClassA
{
public string Name { get; set; }
public List<String> List1 { get; set; }
}
public static void SelectManyMethod()
{
ClassA[] ClassAList =
{ new ClassA { Name="A1",
List1 = new List<string>{ "a11", "a12" } },
new ClassA { Name="B1",
List1 = new List<string>{ "b11", "b12" } },
new ClassA { Name="C1",
List1 = new List<string>{ "c11", "c12" } } };
IEnumerable<string> Result = ClassAList.SelectMany(ClassA => ClassA.List1);

}
Ref : https://msdn.microsoft.com/en-us/library/bb534336.aspx


Q)How can we find out the index of the element using where clause ? (LINQ Interview question-13)
   
  Where((i,ix)=>i==ix)  We could find the index using the lambda expression check the expression given.

Q) Which name space contains necessary classes to provide functionality for LINQ to XML?  (LINQ Interview question-14)
  
  System.XML.Xlinq

Q)What are the three parts of LINQ query operation  (LINQ Interview question-15)

  •    Obtain the data source 
  •    Create the query
  •    Execute the query
Ref : https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/introduction-to-linq-queries

No comments:

Post a Comment

Post Bottom Ad

Pages