Based on Question asked in MSDN Forum
- IN is efficient when most of the filter criteria is in the sub-query.
- EXISTS is efficient when most of the filter criteria is in the main query.
- Usually IN has the slowest performance.
If a condition refers to an aggregate function, put that condition in the HAVING clause. Otherwise, use the WHERE clause.
You can use HAVING but recommended you should use with GROUP BY.
SQL Standard says that WHERE restricts the result set before returning rows and HAVING restricts the result set after bringing all the rows. So WHERE is faster.
InstanceContextMode tells how the instanceContext object need maintain/handle/available for the incoming messages.
What is the Use of InstanceContextMode?
Basically it tell how the object create for the request/response must be handle across the service.
In our Business requirement let see what are all different type of requirement you may face
1) For some of you request you may need to maintain information for the each user and its scope of information is limited to each user (SESSION)
EX:- While a client request to service first time new instance will get created after that request come form same client will handle by the same instance until it gets disconnected/Expired.
2) Some time you need to maintain the information common to all user request to share the information across all the clients
EX: Update each share value to the requested users.
3) Some other request just you want to pass information to service, which may return the value back to client or may not based on your need.
Let see how we can implement it using WCF InstanceContextMode
There are 3 different type of InstanceContextMode
– For every request separate InstanceContext object gets created and destroyed after respond back to the client, just Request/Response pattern.
– Decorate [ServiceBehaviour(InstanceContextMode=InstanceContextMode.PerCall)] for the class that you want to include the InstanceContextMode.
– When first time request comes from the client new object will gets created, after that when ever subsequent call comes from the same client, the request are handle by the same instance object. This object will alive in service untill the client get disconnect or that instance object goes to ideal mode for some time. Default session expire time is 10 min.
– Decorate [ServiceBehaviour(InstanceContextMode=InstanceContextMode.PerSession)] for the class that you want to include the InstanceContextMode.
– This object is global for all the request/response. When ever new request are comes from the client it won;t create new instance because of that performance gets improved.
– Decorate [ServiceBehaviour(InstanceContextMode=InstanceContextMode.Single)] for the class that you want to include the InstanceContextMode.
You need to decorate corresponding servicebehaviour attribute in the class, else it will behave as request/response fromat and also based on how you create object in client side to call the service.
To download the sample code click here
When shall we go for wsDualHttpBinding?
Your service need to perform lot of operation after getting the information from the client side, which consume more time to return result back to the client.
Normally time consuming operation in server side will block the client to perform other operation. So ‘wsDualHttpBinding’ will be ideal solution for this kind of problem.
Suppose if your client not depend on the result produce by the service at that time we can go for ‘wsDualHttpBinding’ .
If you need to implement callback between client and service at that time we can go for ‘wsDualHttpBinding’.
Because of some operation (or) result taking place in server side must not affect the client side access or other request the ideal choice is ‘wsDualHttpBinding’
wsDualHttpBinding is binding which sends the request in one http channel and response will be sent back to the client in another http channel
If you are using ‘dualHttpBinding’ you need to create two interface one interface is to get the request from the client and one more is send the response back to the client as callback
The below mentioned interface is to send the response back to the client and the ‘OperationalContract’ used to send the response back to the client must be decorated with the property ‘IsOneWay=true’ as shown below.
Another Interface mentioned below is to get the request from the client, this interface must also be decorated with the property ‘IsOneWay=true’ inside the ‘OperationalContract’ attribute as mentioned below. Also we need to refer using which interface (or) channel we are going to send the response back to the client. We already declare the callback interface now need to establish relationship with the ‘ServiceContract’ as mentioned below.
In the above code we are mentioned ‘INotificationServiceCalback’ as the callback interface by using ‘CallbackContract’ property of ServiceContract.
In the web.Config we need to specify ‘wsDualHttpBinding’ in the binding property.
The Implementation of service contract
You can find the Code sample here
ASP.NET 5 includes the following features:
1) New flexible and cross-platform runtime
2) New modular HTTP request pipeline
3) Cloud-ready environment configuration
4) Unified programming model that combines MVC, Web API, and Web Pages
5) Ability to see changes without re-building the project
6) Side-by-side versioning of the .NET Framework
7) Ability to self-host or host on IIS
8) New tools in Visual Studio 2015
9) Open source in GitHub
Here are some helpful links to get you started with ASP.NET 5 Preview:
For more information ASP.NET 5 Overview
While i try to call the Web-Api service through JQuery, i am unable to receive the complex type collection in my client side, it throws error message in my console table of my browser as below.
Add the below code in WEB-API project web.config file
<system.webServer> <httpProtocol> <customHeaders> <!-- Adding the following custom HttpHeader will help prevent CORS from stopping the Request--> <add name="Access-Control-Allow-Origin" value="*" /> </customHeaders> </httpProtocol> </system.webServer>