Marshalling
Marshalling (sometimes spelled marshaling) is the process of transforming the memory representation of an object to a data format suitable for storage or transmission, and it is typically used when data must be moved between different parts of a computer program or from one program to another.
Marshalling is similar to serialization and is used to communicate to remote objects with an object.
It simplifies complex communication, using custom/complex objects to communicate instead of primitives.
The opposite, or reverse, of marshalling is called unmarshalling.
Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
25 December 2013
XML VS JSON
XML VS JSON
XML - Extensible Markup Language
JSON - Javascript Object Notation
JSON
JSON uses JavaScript syntax for describing data objects, but JSON is still language and platform independent.
JSON is more lighter and efficient than XML
JSON does not provide any display capabilities because it is not a document markup language.
XML
XML’s strength is extensibility and the avoidance of namespace clashes. It holds any data type and can be used to transport full documents with formatting information included. XML is best used when transporting something like a patient chart or text document with markup included.
XML provide display capabilities.
XML structures are based on elements (which can be nested), attributes (which cannot), raw content text, entities, DTDs, and other meta structures.
Finally,
JSON is a better data exchange format. XML is a better document exchange format. Use the right one for the right job.
XML - Extensible Markup Language
JSON - Javascript Object Notation
JSON
JSON uses JavaScript syntax for describing data objects, but JSON is still language and platform independent.
JSON is more lighter and efficient than XML
JSON does not provide any display capabilities because it is not a document markup language.
XML
XML’s strength is extensibility and the avoidance of namespace clashes. It holds any data type and can be used to transport full documents with formatting information included. XML is best used when transporting something like a patient chart or text document with markup included.
XML provide display capabilities.
XML structures are based on elements (which can be nested), attributes (which cannot), raw content text, entities, DTDs, and other meta structures.
Finally,
JSON is a better data exchange format. XML is a better document exchange format. Use the right one for the right job.
SOAP VS REST
SOAP VS REST
SOAP - "Simple Object Access Protocol"
REST - "Representational state transfer"
REST
Standard and Unified methods like POST, GET, PUT and DELETE. Its work like how an website makes a request using HTTP protocol.
Easy to use URI (Uniform resource identifier) format to locate any web resource.
REST is light weighted compared to SOAP
SOAP
SOAP is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. SOAP uses XML technologies to define an extensible messaging framework, which provides a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics.
WCF SOAP
The WCF SOAP service can be categorized as operations-based, which means that a SOAP client calls a method that is available as a web service operation on a remote server, and receives a SOAP response.
WCF REST
A WCF REST service can be categorized as resource-based, which means that a REST client sends an HTTP request to programmatically accomplish a business objective. These requests largely employ a GET that is sent to a URI. In return, the client receives the corresponding resource.
SOAP - "Simple Object Access Protocol"
REST - "Representational state transfer"
REST
Standard and Unified methods like POST, GET, PUT and DELETE. Its work like how an website makes a request using HTTP protocol.
Easy to use URI (Uniform resource identifier) format to locate any web resource.
REST is light weighted compared to SOAP
SOAP
SOAP is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. SOAP uses XML technologies to define an extensible messaging framework, which provides a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics.
WCF SOAP
The WCF SOAP service can be categorized as operations-based, which means that a SOAP client calls a method that is available as a web service operation on a remote server, and receives a SOAP response.
WCF REST
A WCF REST service can be categorized as resource-based, which means that a REST client sends an HTTP request to programmatically accomplish a business objective. These requests largely employ a GET that is sent to a URI. In return, the client receives the corresponding resource.
1 December 2013
Difference Between Razor View Engine and ASPX View Engine in MVC
Difference Between Razor View Engine and ASPX View Engine in MVC
ASPX View Engine is the default view engine for the Asp.net MVC that is included with Asp.net MVC from the beginning.
Razor Engine is an advanced view engine that was introduced with MVC3. This is not a new language but it is a new markup syntax.
ASPX View Engine doesn't support TDD (Test Driven Development)
Razor Engine supports TDD (Test Driven Development)
ASPX View Engine support design mode in visual studio means you can see your page look and feel without running the application.
Razor Engine, doesn't support design mode in visual studio means you cann't see your design page look and feel.
ASPX View Engine is faster than Razor Engine.
Razor Engine is little bit slow as compared to Webform Engine.
Syntax
Webform uses <% and %>
for example
< %: Html.ActionLink("SignUp", "SignUp") % >
Razor uses @ symbol
for example
@Html.ActionLink("SignUp", "SignUp")
ASPX View Engine does not prevent XSS attacks means any script saved in the database will be fired while rendering the page.
Razor Engine prevents XSS attacks(Cross-Site Scripting Attacks) means it encodes the script or html tags like <,> before rendering to view.
ASPX View Engine is the default view engine for the Asp.net MVC that is included with Asp.net MVC from the beginning.
Razor Engine is an advanced view engine that was introduced with MVC3. This is not a new language but it is a new markup syntax.
ASPX View Engine doesn't support TDD (Test Driven Development)
Razor Engine supports TDD (Test Driven Development)
ASPX View Engine support design mode in visual studio means you can see your page look and feel without running the application.
Razor Engine, doesn't support design mode in visual studio means you cann't see your design page look and feel.
ASPX View Engine is faster than Razor Engine.
Razor Engine is little bit slow as compared to Webform Engine.
Syntax
Webform uses <% and %>
for example
< %: Html.ActionLink("SignUp", "SignUp") % >
Razor uses @ symbol
for example
@Html.ActionLink("SignUp", "SignUp")
ASPX View Engine does not prevent XSS attacks means any script saved in the database will be fired while rendering the page.
Razor Engine prevents XSS attacks(Cross-Site Scripting Attacks) means it encodes the script or html tags like <,> before rendering to view.
17 November 2013
If variable is Empty or NULL in WHERE clause in SQL Server
If variable is Empty or NULL in WHERE clause in SQL Server
If @SearchType is Null or Empty how to return all values from the database.
Sample Query:
SELECT
P.[ProductId],
P.[ProductName],
P.[ProductPrice],
P.[Type]
FROM [Product] P
-- if @Searchtype is not null then use the where clause
WHERE p.[Type] = @SearchType
Just use
If @searchType is null means 'return the whole table' then use
WHERE p.[Type] = @SearchType OR @SearchType is NULL
If @searchType is an empty string means 'return the whole table' then use
WHERE p.[Type] = @SearchType OR @SearchType = ''
If @searchType is null or an empty string means 'return the whole table' then use
WHERE p.[Type] = @SearchType OR Coalesce(@SearchType,'') = ''
If the @SearchType is Null or Empty, it returns all the value from the database.
If the @SearchType contains any value, it returns only the condition satisfied data.
If @SearchType is Null or Empty how to return all values from the database.
Sample Query:
SELECT
P.[ProductId],
P.[ProductName],
P.[ProductPrice],
P.[Type]
FROM [Product] P
-- if @Searchtype is not null then use the where clause
WHERE p.[Type] = @SearchType
Just use
If @searchType is null means 'return the whole table' then use
WHERE p.[Type] = @SearchType OR @SearchType is NULL
If @searchType is an empty string means 'return the whole table' then use
WHERE p.[Type] = @SearchType OR @SearchType = ''
If @searchType is null or an empty string means 'return the whole table' then use
WHERE p.[Type] = @SearchType OR Coalesce(@SearchType,'') = ''
If the @SearchType is Null or Empty, it returns all the value from the database.
If the @SearchType contains any value, it returns only the condition satisfied data.
15 October 2013
Difference between CTE and Temp Table and Table Variable in SQL Server
Difference between CTE and Temp Table and Table Variable in SQL Server
1. Temp Tables are physically created in the Tempdb database. These tables act as the normal table and also can have constraints, index like normal tables.
It is divided into two Local temp tables and Global Temp Table,
Local Temp table are only available to the SQL Server session or connection (means single user) that created the tables.
Global temp tables are available to all SQL Server sessions or connections (means all the user).
These can be created by any SQL Server connection user and these are automatically deleted when all the SQL Server connections have been closed.
cases where you need transaction rollback support.
cases where you need transaction rollback support.
2. CTE - Common table Expression is a named temporary result set which is used to manipulate the complex sub-queries data. This exists for the scope of statement. This is created in memory rather than Tempdb database. You cannot create any index on CTE.
3. Table Variable acts like a variable and exists for a particular batch of query execution. It gets dropped automatically once it comes out of batch. This is also created in the Tempdb database but not the memory.You cannot create a non-clustered index on a table variable, unless the index is a side effect of a PRIMARY KEY or UNIQUE constraint on the table.
If the resultset is small, the table variable is always the optimum choice.
If the resultset is small, the table variable is always the optimum choice.
9 October 2013
Remove duplicates in SQL Server when tables have no primary key
Remove duplicates in SQL Server when tables have no primary key
I have table called CricketerDetails, and the table has no primary or unique key.
Below i have mentioned how to remove duplicate items with query.
1. Procedure to remove the Duplicate rows with query is
Query
WITH tempTable as
(
SELECT ROW_NUMBER() Over(PARTITION BY FirstName,LastName,HighestScore ORDER BY FirstName) As RowNumber,* FROM CricketerDetails
)
DELETE FROM tempTable where RowNumber >1
SELECT * FROM CricketerDetails order by FirstName asc
I have table called CricketerDetails, and the table has no primary or unique key.
Below i have mentioned how to remove duplicate items with query.
1. Procedure to remove the Duplicate rows with query is
Query
WITH tempTable as
(
SELECT ROW_NUMBER() Over(PARTITION BY FirstName,LastName,HighestScore ORDER BY FirstName) As RowNumber,* FROM CricketerDetails
)
DELETE FROM tempTable where RowNumber >1
SELECT * FROM CricketerDetails order by FirstName asc
Subscribe to:
Posts (Atom)
Implementing OAuth validation in a Web API
I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...