Interview Questions
Interview Questions
Interview Questions
MVC stands for Model, View and Controller. MVC separates application into three components -
Model, View and Controller.
Model: Model represents shape of the data and business logic. It maintains the data of the
application. Model objects retrieve and store model state in a database.
View: View is a user interface. View display data using model to the user and also enables them
to modify the data.
Controller: Controller handles the user request. Typically, user interact with View, which in-turn
raises appropriate URL request, this request will be handled by a controller. The controller
renders the appropriate view with the model data as a response.
Points to Remember :
Controller handles user's requests and renders appropriate View with Model data.
try
con.Open();
da.Fill(dataTable);
textBox1.Text = row[2].ToString();
comboBox1.Text = row[3].ToString();
comboBox3.Text = row[4].ToString();
textBox2.Text = row[6].ToString();
comboBox2.Text = row[7].ToString();
comboBox4.Text = row[8].ToString();
}
da.Dispose();
MessageBox.Show(ex.Message);
con.Close();
Entity Framework is an ORM from Microsoft that will enable the developers to work with
domain specific objects, which eliminates the extra code being written in the data access layer.
ADO.NET is faster. "Entity Framework will be around the ADO.NET, which means ADO.NET is
faster than Entity Framework."
We need to write so much code to talk to database. Easy to use. As an Entity Framework will talk
to database without much code involved.
IEnumerable best suitable for in-memory operations because first it will execute “select
query” on server and it will load all the data into client memory then only it will apply all
the filter conditions.
Suppose if we have table called EmployeeDetails in our database from that we need to get
only top 3records where users gender equals to “Male” for this if we
use IEnumerable first it will execute “select query” on database server, it loads all the
records into memory and then it filters the data based on our requirement.
For remote operations IEnumerable is not suggestable and its better use IEnumerable to
perform query operations on in-memory collections like List, Array, etc.
In case if our tables contain more than 1 or 2 lac records then IEnumerable will fetch all
the records into our application memory then it will perform filter conditions due to this our
application becomes very slow.
IEnumerable is beneficial when you want to load all the data from query into memory and
apply further filtering. Its best suitable for LINQ to Objects and LINQ to XML operations.
IQueryable is best suitable for out-memory (remote database) operations because it will
execute select query with all filter conditions on server.
Suppose if we have table called EmployeeDetails in our database from that we need to get
only top 3 records where users gender equals to “Male” for this if we use IQueryable it
will execute “select query along with filter conditions” on database server and it loads
only required records based on our conditions.
In .Net without adding reference to the project we can call in the following ways
What is polymorphism?
Polymorphism provides following features:
It allows you to invoke methods of derived class through base class
reference during runtime.
2. Runtime polymorphism/Overriding
In method overloading method performs the different task at the different input
parameters.
When overriding a method, you change the behavior of the method for the derived
class. Overloading a method simply involves having another method with the same
prototype.
RequiredFieldValidator.
RangeValidator.
CompareValidator.
RegularExpressionValidator.
CustomValidator.
ValidationSummary.
Dependency injection
Web API includes filters to add extra logic before or after action method
executes. Filters can be used to provide cross-cutting features such as
logging, exception handling, performance measurement, authentication and
authorization.
Filters are actually attributes that can be applied on the Web API controller
or one or more action methods. Every filter attribute class must implement
IFilter interface included in System.Web.Http.Filters namespace. However,
System.Web.Http.Filters includes other interfaces and classes that can be
used to create filter for specific purpose.
The following table lists important interfaces and classes that can be used to
create Web API filters.