Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
4 May 2013
Why C# or VB.NET doesn't support multiple inheritance
Why C# or VB.NET doesn't support multiple inheritance
1) First reason is ambiguity around Diamond problem, consider a class A has foo() method and then B and C derived from A and has there own foo() implementation and now class D derive from B and C using multiple inheritance and if we refer just foo() compiler will not be able to decide which foo() it should invoke. This is also called Diamond problem because structure on this inheritance scenario is similar to 4 edge diamond, see below
A foo()
/ \
/ \
foo() B C foo()
\ /
\ /
D
foo()
In my opinion even if we remove the top head of diamond class A and allow multiple inheritances we will see this problem of ambiguity.
Some times if you give this reason to interviewer he asks if C++ can support multiple inheritance than why not c# oR vb.net.In that case I would try to explain him the second reason which I have given below that its not because of technical difficulty but more to maintainable and clearer design was driving factor though this can only be confirmed by any of java designer and we can just speculate. Wikipedia link has some good explanation on how different language address problem arises due to diamond problem while using multiple inheritances.
2) Second and more convincing reason to me is that multiple inheritances does complicate the design and creates problem during casting, constructor chaining etc and given that there are not many scenario on which you need multiple inheritance its wise decision to omit it for the sake of simplicity. Also c# and avoids this ambiguity by supporting single inheritance with interfaces. Since interface only have method declaration and doesn't provide any implementation there will only be just one implementation of specific method hence there would not be any ambiguity.
3 May 2013
WCF FAQ
WCF FAQ
1. What is WCF?
Windows Communication Foundation (WCF) is a framework for building and running service-oriented applications. WCF unifies and extends the functionality of existing Microsoft connecting technologies, providing a single programming model independent of underlying communications protocols. WCF applications can inter operate with other technologies using open standards and protocols. WCF is a combined feature of Web Service, Remoting, MSMQ and COM+.
2.Endpoints - All communications with the WCF service will happen via the endpoints. The endpoint is composed of 3 parts (collectively called as ABC's of endpoint) as defines below:
Address: The endpoints specify an Address that defines where the endpoint is hosted. It’s basically URL.
Ex: http://localhost/WCFServiceSample/Service.svc
Binding: The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted. Various components of the WCF are depicted in the figure below.
"A" stands for Address: Where is the service?
"B" stands for Binding: How can we talk to the service?
"C" stands for Contract: What can the service do for us?
1. What is WCF?
Windows Communication Foundation (WCF) is a framework for building and running service-oriented applications. WCF unifies and extends the functionality of existing Microsoft connecting technologies, providing a single programming model independent of underlying communications protocols. WCF applications can inter operate with other technologies using open standards and protocols. WCF is a combined feature of Web Service, Remoting, MSMQ and COM+.
2.Endpoints - All communications with the WCF service will happen via the endpoints. The endpoint is composed of 3 parts (collectively called as ABC's of endpoint) as defines below:
Address: The endpoints specify an Address that defines where the endpoint is hosted. It’s basically URL.
Ex: http://localhost/WCFServiceSample/Service.svc
Binding: The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted. Various components of the WCF are depicted in the figure below.
"A" stands for Address: Where is the service?
"B" stands for Binding: How can we talk to the service?
"C" stands for Contract: What can the service do for us?
Binding
|
Description
|
BasicHttpBinding
|
Basic
Web service communication. No security by default
|
WSHttpBinding
|
WsHttpBinding sends the message in an encrypted and secured manner.
|
WSDualHttpBinding
|
Similar
to the wsHttpBinding binding, with additional support for duplex
communication and lack of support for transport-level security.
|
WSFederationHttpBinding
|
Web
services with federated security. Supports transactions
|
MsmqIntegrationBinding
|
Communication
directly with MSMQ applications. Supports transactions
|
NetMsmqBinding
|
Communication
between WCF applications by using queuing. Supports transactions
|
NetNamedPipeBinding
|
Communication
between WCF applications on same computer. Supports duplex contracts and
transactions
|
NetPeerTcpBinding
|
Communication
between computers across peer-to-peer services. Supports duplex contracts
|
NetTcpBinding
|
Communication
between WCF applications across computers. Supports duplex contracts and
transactions
|
16 April 2013
ASP.NET, SQL, ADO.NET Video Tutorial
ASP.NET, SQL, ADO.NET Video Tutorial
Friend , Below link is really useful for Beginners
ASP.NET Gridview Video Tutorial
http://www.youtube.com/playlist?list=PL6n9fhu94yhW1NryGv6LxX4U4b07T4RlI
ADO.NET Tutorial for Beginner
http://www.youtube.com/playlist?list=PL6n9fhu94yhX5dzHunAI2t4kE0kOuv4D7
ASP.NET Tutorial for Beginner
http://www.youtube.com/playlist?list=PL6n9fhu94yhXQS_p1i-HLIftB9Y7Vnxlo
SQL Tutorial for Beginner
http://www.youtube.com/playlist?list=PL08903FB7ACA1C2FB
Dotnet Tutorial for Beginner
http://www.youtube.com/playlist?list=PL8598C97BA1D871C1
C# Tutorial for Beginner
http://www.youtube.com/playlist?list=PLAC325451207E3105
Friend , Below link is really useful for Beginners
ASP.NET Gridview Video Tutorial
http://www.youtube.com/playlist?list=PL6n9fhu94yhW1NryGv6LxX4U4b07T4RlI
ADO.NET Tutorial for Beginner
http://www.youtube.com/playlist?list=PL6n9fhu94yhX5dzHunAI2t4kE0kOuv4D7
ASP.NET Tutorial for Beginner
http://www.youtube.com/playlist?list=PL6n9fhu94yhXQS_p1i-HLIftB9Y7Vnxlo
SQL Tutorial for Beginner
http://www.youtube.com/playlist?list=PL08903FB7ACA1C2FB
Dotnet Tutorial for Beginner
http://www.youtube.com/playlist?list=PL8598C97BA1D871C1
C# Tutorial for Beginner
http://www.youtube.com/playlist?list=PLAC325451207E3105
Uses of WCF
Uses of WCF
Interoperability
When
our application is in .Net technologies and when the partner application was
in another platform [J2EE]. It is running different operating
system.[Different Platform]. The security requirement is also quite
different. So to Interoperability with this application WCF play a key role
in interoperable with the application
Unification of Microsoft’s Distributed Computing Technologies, WCF vs.
other technologies
1. ASMX,
also called ASP.NET Web Services, would be an option for communicating with
the Java EE-based reservation application and with the partner applications.
WCF - WCF can
communicate using SOAP-based Web services, interoperability with
other
platforms that also support SOAP
2. .NET Remoting - Remoting
is designed expressly for .NET-to-.NET communication, so it would offer the
best performance for this situation.
WCF - To
allow optimal performance when both parties in a communication are built on
WCF, the wire encoding used in this
case is an optimized binary version of SOAP.
3. Enterprise Services - managing
object lifetimes and defining distributed transactions. But it supports only
limited set of protocols.
WCF - Managing
object lifetimes, defining distributed transactions, and other aspects of
Enterprise Services are
also provided by WCF.
4. Web Services Enhancements
(WSE) - might be used along with ASMX to
communicate, Because it implements more advanced SOAP-based standards, known
collectively as the WS-*specifications, WSE can allow better security.
WCF - it supports a large set of the WS-*
specifications, WCF helps provide reliability,
security, and transactions when
communicating with any platform that also supports these
Specifications.
5. System.Messaging,
which provides a programming interface to Microsoft MessageQueuing (MSMQ) could be used to communicate
with Windows-based partner applications.
WCF –
It has option for queued messaging, built on MSMQ, allows applications to use
Persistent
queuing without needing to use another application programming interface.
6. System.Net developers
can create applications that use the HTTP-based communication style known as
Representational State Transfer (REST).
WCF
- It has built-in support for creating RESTful clients
and services.
|
12 April 2013
IQueryable and IEnumerable
IQueryable and IEnumerable
The IQueryableIEnumerable
1. IEnumerable exists in System.Collections Namespace.
2. IEnumerable can move forward only over a collection, it can’t move backward and between the items.
3. IEnumerable is best to query data from in-memory collections like List, Array etc.
4. While query data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data.
5. IEnumerable is suitable for LINQ to Object and LINQ to XML queries.
6. IEnumerable supports deferred execution.
7. IEnumerable doesn’t supports custom query.
8. IEnumerable doesn’t support lazy loading. Hence not suitable for paging like scenarios.
9. Extension methods supports by IEnumerable takes functional objects.
IEnumerable Example
MyDataContext dc = new MyDataContext ();
IEnumerable< Employee > list = dc.Employees.Where(p = > p.Name.StartsWith("S"));list = list.Take< Employee >(10);
Generated SQL statements of above query will be :
SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
WHERE [t0].[EmpName] LIKE @p0
Notice that in this query "top 10" is missing since IEnumerable filters records on client side
IQueryable
1. IQueryable exists in System.Linq Namespace.
2. IQueryable can move forward only over a collection, it can’t move backward and between the items.
3. IQueryable is best to query data from out-memory (like remote database, service) collections.
4. While query data from database, IQueryable execute select query on server side with all filters.
5. IQueryable is suitable for LINQ to SQL queries.
6.IQueryable supports deferred execution.
7. IQueryable supports custom query using CreateQuery and Execute methods.
8. IQueryable support lazy loading. Hence it is suitable for paging like scenarios.
9. Extension methods supports by IEnumerable takes expression objects means expression tree.
IQueryable Example
MyDataContext dc = new MyDataContext ();
IQueryable< Employee > list = dc.Employees.Where(p => p.Name.StartsWith("S"));
list = list.Take< Employee >(10);
Generated SQL statements of above query will be :SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]WHERE [t0].[EmpName] LIKE @p0
Notice that in this query "top 10" is exist since IQueryable executes query in SQL server with all filters.
4 April 2013
Difference between PostBackTrigger and AsyncPostBackTrigger in ASP.NET
Difference between PostBackTrigger and AsyncPostBackTrigger in ASP.NET
PostBackTrigger
Use the PostBackTrigger control to enable controls inside an UpdatePanel to cause a postback.
Specifies a control and event that will cause a partial page update for the UpdatePanel that contains this trigger reference.
| |
Specifies a control and event that will cause a full page update (a full page refresh). This tag can be used to force a full refresh when a control would otherwise trigger partial rendering.
|
PostBackTrigger
Use the PostBackTrigger control to enable controls inside an UpdatePanel to cause a postback.
Uses of AsyncPostBackTrigger
- For controls that are outside a panel.
- For controls that are inside a panel when the ChildrenAsTriggers property is false.
- For controls that are inside nested panels, in order to cause a refresh of parent panels.
28 March 2013
Multiple File Upload JQuery Asp.net
Multiple File Upload JQuery Asp.net in C#
MultipleFileUpload.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MultipleFileUpload.aspx.cs"
Inherits="MultipleFileUploadJquery.MultipleFileUpload" %>
Include the below script
< script src="Scripts/jquery-1.8.2.js" type="text/javascript">
< script src="Scripts/jquery.MultiFile.js" type="text/javascript">
Code
< form id="form1" runat="server">
< div >
< asp:FileUpload ID="file_upload" class="multi" runat="server" / >
< asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" / >
< asp:Label ID="lblMessage" runat="server" / >
< /div >
< /form >
< /body >
< /html >
MultipleFileUploadJquery,aspx.cs
using System;
using System.IO;
using System.Web;
namespace MultipleFileUploadJquery
{
public partial class MultipleFileUpload : System.Web.UI.Page
{
protected void btnUpload_Click(object sender, EventArgs e)
{
HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
HttpPostedFile uploadfile = fileCollection[i];
string fileName = Path.GetFileName(uploadfile.FileName);
if (uploadfile.ContentLength > 0)
{
uploadfile.SaveAs(Server.MapPath("~/UploadFiles/") + fileName);
lblMessage.Text += fileName +""+ "Saved Successfully";
}
}
}
}
}
Multifile upload Code in C# Visual Studio 2010 are in the following path
http://sdrv.ms/103livW
MultipleFileUpload.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MultipleFileUpload.aspx.cs"
Inherits="MultipleFileUploadJquery.MultipleFileUpload" %>
Include the below script
< script src="Scripts/jquery-1.8.2.js" type="text/javascript">
< script src="Scripts/jquery.MultiFile.js" type="text/javascript">
Code
< form id="form1" runat="server">
< div >
< asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" / >
< asp:Label ID="lblMessage" runat="server" / >
< /div >
< /form >
< /body >
< /html >
MultipleFileUploadJquery,aspx.cs
using System;
using System.IO;
using System.Web;
namespace MultipleFileUploadJquery
{
public partial class MultipleFileUpload : System.Web.UI.Page
{
protected void btnUpload_Click(object sender, EventArgs e)
{
HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
HttpPostedFile uploadfile = fileCollection[i];
string fileName = Path.GetFileName(uploadfile.FileName);
if (uploadfile.ContentLength > 0)
{
uploadfile.SaveAs(Server.MapPath("~/UploadFiles/") + fileName);
lblMessage.Text += fileName +""+ "Saved Successfully";
}
}
}
}
}
Multifile upload Code in C# Visual Studio 2010 are in the following path
http://sdrv.ms/103livW
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; ...