Dot Net Interview Questions and Answers Part 27

1.How to create compiled query in Linq using c#?
Ans. Compiled query will improve performance for the frequently fetching records from the database.
<Func> compiledQuery
= CompiledQuery.Compile>(
(std, rollno) =>from student in std.Students
where student.rollno == rollno
select student);

2.Performance wise "Contains" is good or not?
Ans. Generally we use contains method for checking any values. But internally this is converted to "where in" in sql server that leads to low performance.

3. How to disable the lazy loading in Linq in .net?
Ans. By default lazy loading is enable in Linq. However, we can disable it by using following method,

 context.ContextOptions.LazyLoadingEnabled = false;

4.What is the another name for lazy loading ?
Ans. Deferred loading

5. What is the full form of T4 template and tell me the extension for it?
Ans. T4 full form is text template transformation toolkit.
     The extension for T4 is ".tt".

6. How to disable change tracking for an entity in .net?
Ans. We can disable change tracking for an entity by using MergeOption.
     context.MergeOption = MergeOption.NoTracking;


Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker