Q21. How we can assign an alias to any webapi action method?
Q22. What is the use of LET keyword in linq queries?
Q23. Tell the syntax of inner join and left join in linq queries?
Q24. How to select top 5 records using linq queries. tell me the syntax
Q25. Difference between web service, web api and WCF?
===========================================================================
Q21. How we can assign an alias to any webapi action method?
Answer:
ActionName attribute is an action selector which is used for a different name of the action method.
[ActionName("AliasName")]
example
public class HomeController : Controller{ [ActionName("ListCountries")] public ViewResult Index(){ ViewData["Countries"] = new List<string>{ "India", "Malaysia", "Dubai", "USA", "UK" }; return View(); }
===========================================================================
Q22. What is the use of LET keyword in linq queries?
Answer:
With the help of LET keyword we can utilize the assigned value to the next statement.
for example. in below example avgSalary is calculated on fly to compare it with column emp.salary.
===========================================================================
Q23. Tell the syntax of inner join and left join in linq queries?
Answer:
Inner Join
Left Join
In order to perform the left outer join using query syntax, you need to call the DefaultIfEmpty() method on the results of a group join.
Step1: The first step to implement a left outer join is to perform an inner join by using a group join
Step2: we need to call the DefaultIfEmpty() method on each sequence of matching elements from the group join.
===========================================================================
Q24. How to select top 5 records using linq queries. tell me the syntax
Answer:
Using orderby and then 'Take'
var list = (from t in ctn.Items
where t.DeliverySelection == true && t.Delivery.SentForDelivery == null
orderby t.Delivery.SubmissionDate
select t).Take(5);
===========================================================================
Q25. Difference between web service, web api and WCF?
Answer:
Webapi is a type of webservice. All webapi is a webservice but not all webservice are webapis
Webservices are of two type SOAP and REST.
Web service is something is provided over the web but it is different from web application. it work response and request but not on User interface.
WebService - usually SOAP based
1. Simple object access protocol.
2. It is purely XML based
3. Data can be transferred over http, smtp, ftp etc
4. Performance is less as compared to REST
5. Webmethods [web method] were used as an attribute to methods to make webservice enabled.
WebAPI- only REST based
1. Representational state transfer protocol.
2. It is based on both XML and JSON.
3. Transfer data over http.
4. Performance is good as compared to SOAP.
5. It can be hosted within application or on IIS.
WCF
1. It is SOAP based and return only XML.
2. It is the evolution of the web service(ASMX) and support various protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ.
3. The main issue with WCF is, its tedious and extensive configuration.
4. It can be hosted with in the application or on IIS or using window service.




No comments:
Post a Comment