Quote for the Week

"Learn to enjoy every moment of your life"

Tuesday, September 30, 2014

Difference Between ADO.Net & LINQ to SQL

Introduction


Even though on a low level, LINQ may itself use subsets of ADO - this article focuses more on the programming aspect as a comparison between the two. I am also aware of the slight difference in "run-time" speed, in terms of data access times. However, again - we focus on differences during the development or "design-time" aspect thereof.

About ADO.Net

ADO.Net is an acronym for Advanced Data Objects. It is a subset of the .Net framework. The first versions which were "non .Net", were separate libraries for accessing data. However, as the of .Net Framework it has been incorporated as part thereof.

Accessing SQL based databases using ADO.Net is fast and efficient. However, data is often returned as different types or custom types, and have to be cast or formatted into usable or .Net or native types.

However, when working with web services, like WCF Services and Silverlight, it's a breeze to query data, compile the objects and send them across the service.

I will not go into a too detailed discussion regarding ADO.Net as it's been used for a long time and that is how most of the .Net developers access data.

About LINQ

LINQ is an acronym for Language INtegrated Query. For the purpose of this article, which focuses on C#, .Net and MS-SQL based data mainly, you may understand LINQ as the following: C# Syntax like SQL.

You must understand that any possible collection of objects can be queries with LINQ, where SQL is mostly related to data and querying databases. For example, you may query the Windows file system (like your C drive) as if it were a database or a collection of data - however, we will not look at that during this article.

The reason why LINQ is (or can be) so popular with developers, and me at least, is that it allows you to stay in your native programming language (C# in this instance) and query data, or any other collection of objects for that matter. Another nice feature, is the comparable native types it uses to build and return these objects.

Another problem I have with LINQ, is that it basically creates "it's own" version of the objects returned. This is not really a problem - and actually, it's one of the best features. It does a lot of the work for you. Let me explain. If you go through the process of creating a new database, it's data structures, communication layers, business rules, data entry and exist points, and start working with larger projects where such data libraries are shared between teams, you can imagine how complicated the SQL, Stored Procedures, etc. can get. As well as where things (like business rules) are located, in the database, or in the libraries. (But that is another can of worms for another article)

But let's get back to that problem I started the previous paragraph with - the issue I have, if you query (lets say) the user table, it will build user objects based on the data structure. If you then want to send this across a WCF service for instance, it creates a very hairy and difficult scenario to overcome. You have to either work some black magic with inheritance or even darker magic with WCF data contracts and really get your hands dirty in the WCF frameworks. However, it's so cumbersome you may actually completely get side-tracked and forget you are actually working with data, fetching it and returning it - and not communication layers and protocols. Another way, is to recreate each class or object entity, and write interfaces, or perhaps try and only work with native types in the methods. Other ways may exist, but this entire situation is a bit of a sticky one - I'm working on better ways to handle them every year. I will publish an article on my best solution in the near future.

However, if your application is less widely scoped, lets say, you have a typical .Net Windows App (WPF or Win-Forms) over a fast company network, linked to a database server - you will regret not using LINQ. It's only problematic when you start combining WCF or web services and LINQ.

Summary:

 Have Any Questions, Most welcome, just mail to  dotnetcircle@gmail.com

Monday, September 29, 2014

Garbage Collection - C#

What is garbage?


“Garbage” consists of objects created during a program’s execution on the managed heap that are no longer accessible by the program. Their memory can be reclaimed and reused with no averse effects.


What is the garbage collector?


The garbage collector is a mechanism which identifies garbage on the managed heap and makes its memory available for reuse. This eliminates the need for the programmer to manually delete objects which are no longer required for program execution. This reuse of memory helps reduce the amount of total memory that a program needs to run. In technical terms, we say that it keeps the program’s “working set” small.

How does the garbage collector identify garbage?


In Microsoft’s implementation of the .NET framework the garbage collector determines if an object is garbage by examining the reference type variables pointing to it. In the context of the garbage collector, reference type variables are known as “roots”. Examples of roots include:




  1. A reference on the stack
  2. A reference in a static variable
  3. A reference in another object on the managed heap that is not eligible for garbage collection
  4. A reference in the form of a local variable in a method
  5. Take the following method.


void CreateList()
{
var myList = new List<object>();
myList.Add(new object());
myList.Add(new object());
myList.Add(new object());
Console.WriteLine("Objects added!");
}

When the method starts to execute, a List<object> is instantiated on the managed heap along with several objects. The List contains a root to each of the objects, and the stack contains a root to the List. While the method is executing, all of these roots are accessible from within the program and are considered to be “active”. When the method finishes executing, the stack is cleaned up, removing the root pointing to the List. The List is now no longer accessible within the program. All of the roots contained by the List (those pointing to the objects) are now considered to be “inactive”.

The garbage collector identifies garbage by examining an application’s roots. Objects which have no active roots pointing to them are considered to be garbage.


How does the garbage collector manage to collect garbage without impacting application performance?


The truth is that the garbage collector does impact application performance. However, Microsoft has done a very good job at ensuring that it runs as quickly and efficiently as possible, and its impact is virtually unnoticeable from a user standpoint. It manages to do this by employing a wide variety of strategies and optimisations, a few of which we’ll talk about here.

Reference tracking optimisations


When the garbage collector begins a collection, it starts by setting a bit on every object which could potentially be garbage to 0. This marks these objects for collection. It then traverses the active roots in the application and sets that bit to 1 on every object which is not in fact garbage.

Remember from our previous example that when an object is considered not to be garbage, all objects that it references are also considered not to be garbage. This means that marking a single object as not garbage (such as a List) can result in hundreds or thousands of others also being marked. The garbage collector makes this process more efficient by examining the garbage collection bit before marking a given object. If the bit is already set to 1, it simply moves on, knowing that the object and its roots and their roots and so on and so forth have already been traversed. This makes the marking process significantly more efficient.


Generations in Managed Heap

1. Generation 0

This is the youngest generation and contains the newly created objects. Generation 0 has short-lived objects and collected frequently. The objects that survive the Generation 0 are promoted to Generation 1.
Example : A temporary object.

2. Generation 1

This generation contains the longer lived objects that are promoted from generation 0. The objects that survive the Generation 1 are promoted to Generation 2. Basically this generation serves as a buffer between short-lived objects and longest-lived objects.

3. Generation 2

This generation contains the longest lived objects that are promoted from generation 1 and collected infrequently.
Example : An object at application level that contains static data which is available for the duration of the process.

Compacting


When the runtime allocates heap memory, it attempts to do so in a linear fashion. Objects are created one after another on the heap, and the runtime makes use of what is called the “next object pointer” to know where to place the next object. As you can imagine, however, once a garbage collection has taken place, the once smooth, contiguous block of memory that made up the heap is left full of holes. However, the garbage collector doesn’t leave the heap in this state*. Instead, it embarks on a compacting phase, whereby it moves objects back towards the beginning of the heap, filling the reclaimed memory spaces in the process.

As you can imagine, moving objects around is no trivial matter. When an object is moved in memory, existing references to it need to be updated. This understandably requires that program execution be suspended, as to ensure that all references to a given object are valid at all times during program execution. The CLR attempts to make this suspension as painless as possible by fine-tuning how and when garbage collection executes. Details of these techniques go beyond the scope of this article, but can be found here on the MSDN website.

Smart invocation


The garbage collector ensures that it only collects garbage when it really needs to by setting out a memory budget for each of its three generations. These budgets can be modified by the CLR throughout program execution in order to be as well-adapted as possible to the execution conditions of a given program. When generation 0 of the managed heap surpasses its budget, the garbage collection process begins. The garbage collector checks to see if any other generations have surpassed their budgets, and then decides which generations to actually collect. This often means that garbage collection is only performed on a portion of the objects living on the managed heap, which makes the process significantly more efficient.

It is important to note that while the majority of garbage collections in an average program are invoked when generation 0 exceeds its memory budget, garbage collections can also be triggered by other events. These include the system reporting low memory conditions, the unloading of an AppDomain, the shutting down of the CLR, or a manual call to the GC.Collect method**.

Final word


Hopefully this article will have given you a broad idea of how the garbage collector works in Microsoft’s implementation of the .NET Framework. The garbage collector is a very, very complex mechanism which could merit its own book, and this article by no means constitutes a deep dive into its inner workings. Instead, I’ve attempted to provide a simple and concise explanation of the key talking points, with hopes that it will give you a basic understanding of what goes on behind the scenes in your .NET programs.

Friday, September 26, 2014

Stored Procedure in SQL Server

Introduction

Today, I am going to explain, what is stored procedure in SQL and advantage of stored procedure in SQL and something more about stored procedure how to create stored. So, I am trying to explain stored procedure with example.

What is stored procedure?

Stored Procedure is a group of pre-compiled Transact SQL statement into a single execution plan. It reduces the network traffic and increase the performance because of the commands in stored procedure is executed as single batch of code.

Stored procedure can be reuse in the application. It contains programming statement that performs operation in the database. It stored in database in physical location.


Create Stored Procedure

To create a new stored procedure use “Create procedure” or “Create Proc” command. 

CREATE PROC 
usp_GetAllStudent 
AS BEGIN s
select * from Student 
END


Modify Stored Procedure 


For modifying the stored procedure 

ALTER PROC 
usp_GetAllStudent 
AS BEGIN
select * from Student 
END

Delete Stored Procedure 


If there is requirement to delete the stored procedure, simply drop it using Drop command.

drop proc usp_GetAllStudent 

Execute Stored Procedure

Exec or Execute command is used for executing the stored procedure

EXEC usp_GetAllStudent

Stored Procedure with parameter [input or output]


If there is requirement to create stored procedure based on condition then you can create a stored procedure which takes parameters. Parameters can be input or output. Stored procedure takes input and output both type of parameters.

Example for Input Parameter

CREATE PROC 
usp_GetStudentById @StudentId int 
AS BEGIN
 select * from Student where StudentId=@StudentId; 
END

Execute like this

EXECUTE usp_GetStudentById 1

Example for Output prameter

CREATE PROC 
usp_GetStudentAddressByID 
@StudentId int, @Address varchar(255) OUTPUT 
AS BEGIN 
SELECT @Address=Address FROM Student 
WHERE StudentId=@StudentId; 
END

Execute like this

DECLARE 
@Address varchar(255) 
EXEC usp_GetStudentAddressByID 1, 
@Address OUTPUT SELECT @Address 
AS StudentAddress 


Advantage of stored procedure


There are so many advantage to use stored procedure rather than a simple query.

Reduce network traffic

Stored procedures are precompiled so there is no need to compile every time. It reduces the network traffic because of it executes in single execution plan. Stored procedure is also cached on the server.

Security

When we call a stored procedure over the network, we can execute stored procedure based on your parameter but we can see the table and database object name.

Maintainability

Stored procedure scripts are in one location so updating and tracking of dependencies based on schema changes becomes easier. Stored procedure can be tested independent of the application


Types of stored procedures


User defined Stored Procedure

User defined stored procedure can be created in user defined database or any other database except the resource database.

System defined Stored Procedure

System defined stored procedure is physically stored into hidden Resource database and logically we can find in sys schema of every system. Msdb database also contain system define stored procedure in dbo schema.  It basically starts with sp_ prefix.

Temporary Stored Procedure

Temporary stored procedure is also type of user defined stored procedure. It stored in tempdb. As like temporary table it is also two type Local temporary stored procedure and Global temporary stored procedure.

Remote Stored Procedure

Remote stored procedure basically created and stored on remote server database. and these remote procedure can be accessed from other server.


NOTE:

Don't use sp_ prefix to create stored procedure. It is a standard naming convention that is used in master database.  If you use sp_ , Sql server will first search stored procedure in master database and after that it will search user database. So, avoid it. you can use usp_ or other prefix as you like.

Conclusion

So, Here We learn what is stored procedure and how we can create, drop, update and execute stored procedure. and we also learned advantage of stored procedure and types of stored procedure.

I hope this post will help you. Please put your feedback using comment which helps me to improve myself for next post or send mail to dotnetcircle@gmail.com. If you have any doubts please ask your doubts or query in the comment section and If you like this post, please share it with your friends. Thanks.


Thursday, September 25, 2014

C# - Collections & Collection Interfaces

Collections


A collection is a set of related objects. Unlike arrays, a collection can grow and shrink dynamically as the number of objects added or deleted. A collection is a class, so you must declare a new collection before you can add elements to that collection.


This classes are specialized classes for data storage and retrieval. These classes provide support for stacks, queues, lists, and hash tables. Most collection classes implement the same interfaces.

Collection classes serve various purposes, such as allocating memory dynamically to elements and accessing a list of items on the basis of an index etc. These classes create collections of objects of the Object class, which is the base class for all data types in C#.




ArrayList It represents ordered collection of an object that can be indexed individually. It is basically an alternative to an array. However unlike array you can add and remove items from a list at a specified position using an index and the array resizes itself automatically. It also allows dynamic memory allocation, add, search and sort items in the list.
Hashtable t uses a key to access the elements in the collection. A hash table is used when you need to access elements by using key, and you can identify a useful key value. Each item in the hash table has a key/value pair. The key is used to access the items in the collection.
SortedList It uses a key as well as an index to access the items in a list. A sorted list is a combination of an array and a hash table. It contains a list of items that can be accessed using a key or an index. If you access items using an index, it is an ArrayList, and if you access items using a key , it is a Hashtable. The collection of items is always sorted by the key value.
Stack It represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items. When you add an item in the list, it is called pushing the item and when you remove it, it is called popping the item.
QueueIt represents a first-in, first out collection of object. It is used when you need a first-in, first-out access of items. When you add an item in the list, it is called enqueue and when you remove an item, it is called deque.
BitArrayIt represents an array of the binary representation using the values 1 and 0. It is used when you need to store the bits but do not know the number of bits in advance. You can access items from the BitArray collection by using an integer index, which starts from zero.

Collection Interfaces


All of the collection types use some common interfaces. These common interfaces define the basic functionality for each collection class. The key collections interfaces are – IEnumerable, ICollection, IDictionary and IList.


                                    

IEnumerable acts as a base interface for all the collection types that is extended by ICollection. ICollection is further extended by IDictionary and IList.



Interface Description
IEnumerableProvides an enumerator which supports a simple iteration over a non-generic collection.
ICollectionDefines size, enumerators and synchronization methods for all nongeneric collections.
IDictionaryRepresents a nongeneric collection of key/value pairs.
IListRepresents a non-generic collection of objects that can be individually accessed by index.



All collections interfaces are not implemented by all the collections. It depends on collection nature. For example, IDictionary interface would be implemented by only those collection classes which support key/value pairs, like HasTable and SortedList etc.

Monday, September 22, 2014

Sessions - How To Pass Information Between Web Pages

One of the most fundamental topics in web design is understanding how to pass information collected on one web page to another web page. There are many different ways you could do this: Cookies, Database... However, I'm going to cover how to use Sessions.

Sessions are used to store information in order to use it during later page requests or in other web pages in a web application. By default Cookies are used to identify which session belongs to which browser. There is an option that you can set in your web.config file to use Cookieless Sessions; however you should keep in mind that for most web applications the Session ID should be kept private and when using Cookieless Sessions the Session ID is displayed in the query string.

In .NET there are three session states: InProc, StateServer, and SQLServer.
By default web applications are set up to use InProc.


Where are Sessions stored?

InProc

The session is kept as live objects on web server (aspnet_wp.exe). It is stored in memory and is the fastest out of the three options; however, you should keep in mind that the more data you store in session, the more memory on the web server is consumed. This could affect the performance of your applications running on the web server. Also keep in mind that you cannot use InProc sessions in a web garden for many reasons I'm not going to get into.

StateServer

The session is serialized and stored in memory in a separate process (aspnet_state.exe). State Server can run on another machine, whereas InProc is specific to the machine the website is running on. You should keep in mind that the cost of serialization/deserialization of the session can affect performance if you're storing lots of objects.

SQLServer

The session is serialized and stored in a table in an SQL server. It requires you have a database available and you should think about how you are going to secure the connection to the database. This is the slowest of the three options but is required in order to store persistent data.

How do I use Sessions in my web application

It is very simple,

public void Page_Load()
{
        
         Session["EMPLOYEE"]="Dot-net-circle"; // Assigning value to the Session
 
}

How to Get it?

In other pages, get the  Employee name as

string employeeName=Session["EMPLOYEE"].ToString().


Summary:


What Do you think, is it helpful to you? You can subscribe for more dot net concepts. Please share to your friends.






Wednesday, September 17, 2014

Object-Oriented Programming Concepts in.NET



Classes, Objects, and Structures in .NET


Summary

The following article kicks off a three-part article series that will present definitions and samples for different Object-Oriented Programming concepts and its implementation in .NET. The first part will examine the concepts of classes, objects, and structures. The second part will examine the concepts of inheritance, abstraction, and polimorphism. The third and last part will examine the concepts of interface, multiple interface inheritance, collections, and overloading.

Introduction

Object-Oriented Programming (OOP) is a software development paradigm that suggests developers to split a program in building blocks known as objects. The OOP paradigm allows developers to define the object’s data, functions, and its relationship with other objects.

Microsoft created the .NET Framework using OOP, and knowing this concepts has helped me to understand the .NET Framework and to design and develop better software components. The purpose of this article is to describe the basic OOP concepts using real world scenarios and to provide some code samples that demonstrate how to work with OOP and .NET.

Class

The most common definition states that a class is a template for an object. Suppose that someone builds a paper pattern for a shirt. All the shirts done with the same paper pattern will be identical (same design, size, etc.). In this sample, the paper pattern is the class and the shirt is the object. To build the same exact shirt over and over, you need the paper pattern as a template.  Another great example are house plans and blueprints. The plans and blueprints define the number of rooms, the size of the kitchen, the number of floors, and more. In this real world sample, the house plans and blueprints are the class and the house is the object. In OOP you program a class as a template for a specific object or groups ob objects that will always have the same features.

Class members

A class has different members, and developers in Microsoft suggest to program them in the following order:

Namespace: 
The namespace is a keyword that defines a distinctive name or last name for the class. A namespace categorizes and organizes the library (assembly) where the class belongs and avoids collisions with classes that share the same name.

Class declaration: Line of code where the class name and type are defined.

Fields: Set of variables declared in a class block.

Constants: Set of constants declared in a class block.

Constructors: A method or group of methods that contains code to initialize the class.

Properties: The set of descriptive data of an object.

Events: Program responses that get fired after a user or application action.

Methods: Set of functions of the class.

Destructor: A method that is called when the class is destroyed. In managed code, the Garbage Collector is in charge of destroying objects; however, in some cases developers need to take extra actions when objects are being released, such as freeing handles or deallocating unmanaged objects. In .NET, there is no concept of deterministic destructors. The Garbage Collector will call the Finalize() method at a non-deterministic time while reclaiming memory for the application.

Access keywords:Access keywords define the access to class members from the same class and from other classes. The most common access keywords are:

Public: Allows access to the class member from any other class.

Private: Allows access to the class member only in the same class.

Protected: Allows access to the class member only within the same class and from inherited classes.

Internal: Allows access to the class member only in the same assembly.

Protected internal: Allows access to the class member only within the same class, from inherited classes, and other classes in the same assembly.

Static: Indicates that the member can be called without first instantiating the class.

The following sample code illustrates a sample class in C#:

/// C#
///Imported namespaces
using System;

/// Namespace: Consider using CompanyName.Product.ComponentType
namespace DotNetTreats.OOSE.OOP_CSharp {
    
    ///Class declaration
    public class employee {
    
        ///Fields
        private string _name;
        private int _salary;
        
        ///Constants
        private const int anualBonus = 1000;
        
        ///Constructor
        public employee(){
        }

        ///Properties
        public string Name {
            get {
                return _name;
            }
            set {
                _name = value;
            }
        }
        public int Salary {
            get {
                return _salary;
            }
            set {
                _salary = value;
            }
        }

        /// Event handlers
        public event EventHandler OnPromotion {
            add {
            }
            remove {
            }
        }

        /// Methods
        public void DuplicateSalary() {
            _salary = _salary*2;
        }

    }
}

Object


Objects are the building blocks of OOP and are commonly defined as  variables or data structures that encapsulate behavior and data in a programmed unit. Objects are items that can be individually created, manipulated, and represent real world things in an abstract way.

Object composition

Every object is composed by:

Object identity: Means that every object is unique and can be differentiated from other objects.  Each time and object is created (instantiated) the object identity is defined.
Object behavior: What the object can do. In OOP, methods work as functions that define the set of actions that the object can do.
Object state: The data stored within the object at any given moment. In OOP, fields, constants, and properties define the state of an object.
Structures

Not everything in the real world should be represented as a class. Structures are suitable to represent lightweight objects. Structures can have methods and properties and are useful for defining types that act as user-defined primitives, but contain arbitrary composite fields. The .NET Framework defines some structures such as System.Drawing.Rectangle, System.Drawing.Point, and System.Drawing.Color.

The following code sample represents a structures in C#:

/// C#
struct Point {
    private int _x;
    private int _y;

    Point(int x, int y){
        this._x = x;
        this._y = y;    
    }

    public int X {
        get {
            return _x;
        }
        set {
            _x = value;
        }
    }

    public int Y {
        get {
            return _y;
        }
        set {
            _y = value;
        }
    }
}

Conclusion

OOP is full of abstract concepts, and the best approach to understand them is practical and not only theoretical. I learned more OOP after making some designs and after implementing some components. The concepts presented in this article might clarify the meaning, but I strongly recommend to go and have fun playing around with OOP. In this article, I examined the concept of classes, objects, and structs. The second part will examine the concepts of inheritance, abstraction, and polimorphism.

Reference

Matt Weisfeld,  The Object-Oriented Thought Process, SAMS, 2000.
Don Box, Chris Sells,  Essential .NET, Addison-Wesley, 2002.

Tuesday, September 16, 2014

How to Store and Retrieve images from SQL server database using asp.net?


Introduction


In this article, I will show you how to store images into sql server table and display in gridview control in the page using asp.net and sql server stored procedure.


Prepare Database Table and store procedure:


First design the database table and stored procedure to store and retrieve image information from database table. Execute the below table and store procedure script into your test database before design your asp.net page.

CREATE TABLE [dbo].[tblUploadedImagedetails](
 [ImageID] [int] IDENTITY(1,1) NOT NULL,
 [ImageName] [varchar](100) NOT NULL,
 [ImageContent] [image] NOT NULL,
 [Createdby] [varchar](100) NOT NULL,
 [CreatedDt] [datetime] NOT NULL,
 [Updatedby] [varchar](100) NULL,
 [UpdatedDt] [datetime] NULL,
 [Active] [bit] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


Below sql server stored procedure will be used to insert the images details, select all images from database and select specific image from table based on image id.


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[SP_ImageUpload]
(        
@pvchImageId   int  =0,        
@pvchImageName  varchar(100)=null,        
@pvchImage   image=null,        
@pvchCreatedBy  varchar(100)=null,        
@pvchAction   varchar(50)=null,        
@pIntErrDescOut  int output
)        
AS        
BEGIN        
  if(@pvchAction='select' and @pvchImageId=0)     
  begin
   select ROW_NUMBER()OVER (ORDER BY ImageID) as rowid ,ImageID, ImageName, ImageContent from tblUploadedImagedetails
   ;
  end
   if(@pvchAction='select' and @pvchImageId!=0)     
  begin
   select ROW_NUMBER()OVER (ORDER BY ImageID) as rowid ,ImageID, ImageName, ImageContent from tblUploadedImagedetails
   where ImageID = @pvchImageId;
  end
  else if(@pvchAction='insert')
  begin
  
  INSERT INTO tblUploadedImagedetails(ImageName,ImageContent,Createdby,CreatedDt,active)
  VALUES(@pvchImageName,@pvchImage,@pvchCreatedBy,GETDATE(),1);
  end
    IF (@@ERROR <> 0)         
   BEGIN         
  SET @pIntErrDescOut = 1        
   END        
  ELSE        
   BEGIN        
  SET @pIntErrDescOut = 0        
   END    
END

ASP.NET project


Create an asp.net project and drag the file upload to upload images and gridvew control to display the stored images into the aspx page. Take the below code and place into your aspx page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SaveImagesToDB._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <title></title>
</head>

<body>
    <form id="form1" runat="server">

    <div>
        <h2 style="color: #0066FF; font-weight: bold;">
            <u>Save Image to SQL server</u></h2>
    </div>

    <div>
        <asp:FileUpload ID="ImageUploadToDB" Width="300px" runat="server" />
        <asp:Button ID="btnUploadImage" runat="server" Text="Save Image to DB" OnClick="btnUploadImage_Click"
            ValidationGroup="vg" /><br />

        <br />
        <asp:Label ID="lblMsg" runat="server" ForeColor="Green" Text=""></asp:Label>
        <h2 style="text-decoration: underline; font-weight: bold; color: #0066FF;">
            Image list Details
        </h2>
        <asp:GridView ID="GridViewUploadedImageFile" runat="server" EmptyDataText="No files found!"
            AutoGenerateColumns="False" Font-Names="Verdana" AllowPaging="true" PageSize="5"
            Width="40%" OnPageIndexChanging="GridViewUploadedImageFile_PageIndexChanging"
            BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" OnRowDataBound="GridViewUploadedImageFile_RowDataBound"
            DataKeyNames="ImageID,ImageContent">

            <AlternatingRowStyle BackColor="#FFD4BA" />

            <HeaderStyle Height="30px" BackColor="#FF9E66" Font-Size="15px" BorderColor="#CCCCCC"     BorderStyle="Solid" BorderWidth="1px" />

            <RowStyle Height="20px" Font-Size="13px" HorizontalAlign="Center" BorderColor="#CCCCCC" BorderStyle="Solid"         BorderWidth="1px" />
            <Columns>
                <asp:BoundField DataField="rowid" HeaderText="#" HeaderStyle-Width="10%" />
                <asp:BoundField DataField="ImageID" HeaderText="#" Visible="false" HeaderStyle-Width="10%" />               
                <asp:BoundField DataField="ImageName" HeaderText="Image Name" HeaderStyle-Width="25%" />
                <asp:TemplateField HeaderText="List of Images" HeaderStyle-Width="40%">
                    <ItemTemplate>
                        <asp:Image ID="UsrImages" runat="server" Height="35px" Width="35px" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
</html>


Namespace Used:

using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.IO;
using System.Data;
using System.Configuration;

Store image to SQL server table :


In code behind part, place the below code in upload button click event and this will store the uploaded image into database table. First we need to verify whether the image is selected or not when clicks on the btnUploadImage button and convert the image into byte array then store into database table. If image is selected then gets the image name using GetFileName method to store the image name into database table. Then get the size of an uploaded image file and store into byte array and using httppostedfile InputStream read method read the file into the byte array and store into database table. Below I’m using sql server stored procedure SP_ImageUpload to insert the images details into table. Once uploaded images saved into table then display the image into page using LoadImages()method.

protected void btnUploadImage_Click(object sender, EventArgs e)
        {
            string ImageName = string.Empty;
            byte[] Image = null;
            if (ImageUploadToDB.PostedFile != null && ImageUploadToDB.PostedFile.FileName != "")
            {
                ImageName = Path.GetFileName(ImageUploadToDB.FileName);
                Image = new byte[ImageUploadToDB.PostedFile.ContentLength];
                HttpPostedFile UploadedImage = ImageUploadToDB.PostedFile;
                UploadedImage.InputStream.Read(Image, 0, (int)ImageUploadToDB.PostedFile.ContentLength);
            }
            using (SqlConnection Sqlcon = new SqlConnection(strCon))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    Sqlcon.Open();
                    cmd.Connection = Sqlcon;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "SP_ImageUpload";
                    cmd.Parameters.Add(new SqlParameter("@pvchAction", SqlDbType.VarChar, 50));
                    cmd.Parameters.Add(new SqlParameter("@pvchImageName", SqlDbType.VarChar, 100));
                    cmd.Parameters.Add(new SqlParameter("@pvchImage", SqlDbType.Image));
                    cmd.Parameters.Add(new SqlParameter("@pvchCreatedBy", SqlDbType.VarChar, 100));
                    cmd.Parameters.Add("@pIntErrDescOut", SqlDbType.Int).Direction = ParameterDirection.Output;
                    cmd.Parameters["@pvchAction"].Value     = "insert";
                    cmd.Parameters["@pvchImageName"].Value  = ImageName;
                    cmd.Parameters["@pvchImage"].Value      = Image;
                    cmd.Parameters["@pvchCreatedBy"].Value  = "Admin";
                    cmd.ExecuteNonQuery();
                    int retVal = (int)cmd.Parameters["@pIntErrDescOut"].Value;
                }
            }
            LoadImages();
        }

Retreive image from SQL server table:

Once uploaded images inserted into table then need to display in the aspx page using gridview control. Below LoadImages() method will be used to display the images in gridview control. Here I’m using stored procedure to get all image record from database. To display this uploaded images we need to use http handler, so right click on project and click Add new item then select Generic handler and changed the name as DisplayImage.ashx then place the below code in httphandler class and using this handler we get the specific image from database and convert as memorystream object then create an image from memory stream and save this image in specific stream and specific format.

string strCon = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlDataAdapter SqlAda;
        DataSet ds;
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadImages();
            }
        }
        private void LoadImages()
        {
            using (SqlConnection Sqlcon = new SqlConnection(strCon))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    Sqlcon.Open();
                    cmd.Connection = Sqlcon;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "SP_ImageUpload";
                    cmd.Parameters.Add(new SqlParameter("@pvchAction", SqlDbType.VarChar, 50));
                    cmd.Parameters["@pvchAction"].Value = "select";
                    cmd.Parameters.Add("@pIntErrDescOut", SqlDbType.Int).Direction = ParameterDirection.Output;
                    SqlAda = new SqlDataAdapter(cmd);
                    ds = new DataSet();
                    SqlAda.Fill(ds);
                    GridViewUploadedImageFile.DataSource = ds;
                    GridViewUploadedImageFile.DataBind();
                }
            }
        }
protected void GridViewUploadedImageFile_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string ImageID = GridViewUploadedImageFile.DataKeys[e.Row.RowIndex].Values[0].ToString();
                System.Web.UI.WebControls.Image UsrImages = (System.Web.UI.WebControls.Image)e.Row.FindControl("UsrImages");
                UsrImages.ImageUrl = "DisplayImage.ashx?ImgId=" + ImageID;
            }
        }

In the above gridview rowdatabound event, pass the image id to httphandler to display the image from database.

DisplayImage Handler:


public class DisplayImage : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
             context.Response.Clear();
             context.Response.ContentType = "image/jpeg";           
              if (context.Request.QueryString["ImgId"] != null)
            {
                int imgId = 0;
                imgId = Convert.ToInt16(context.Request.QueryString["imgId"]);
                MemoryStream memoryStream = new MemoryStream(GetImageFromDB(imgId), false);
                System.Drawing.Image imgFromDataBase = System.Drawing.Image.FromStream(memoryStream);
                imgFromDataBase.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);            }
        }
        private byte[] GetImageFromDB(int ImgId)
        {
            string strCon   = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlDataAdapter SqlAda;
            DataSet ds;
            byte[] btImage  = null;
            using (SqlConnection Sqlcon = new SqlConnection(strCon))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    Sqlcon.Open();
                    cmd.Connection = Sqlcon;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "SP_ImageUpload";
                    cmd.Parameters.Add(new SqlParameter("@pvchAction", SqlDbType.VarChar, 50));
                    cmd.Parameters.Add(new SqlParameter("@pvchImageId", SqlDbType.Int));
                    cmd.Parameters["@pvchAction"].Value = "select";
                    cmd.Parameters["@pvchImageId"].Value = ImgId;
                    cmd.Parameters.Add("@pIntErrDescOut", SqlDbType.Int).Direction = ParameterDirection.Output;
                    SqlAda = new SqlDataAdapter(cmd);
                    ds = new DataSet();
                    SqlAda.Fill(ds);
                    btImage = (byte[])ds.Tables[0].Rows[0][3];
               }
            }
            return btImage; 
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }


See the below screen shot, after inserting the images into table, gridview displays the list of saved images in the page.




What do you think, is this Article is interesting, please share this Article to your friends.

Any quries? Please send a mail to dotnetcircle@gmail.com

Monday, September 15, 2014

Software Development Life Cycle(SDLC)









What is SDLC? 

SDLC stands for Software Development Life Cycle. A Software Development Life Cycle is essentially a series of steps, or phases, that provide a model for the development and lifecycle management of an application or piece of software. The methodology within the SDLC process can vary across industries and organizations, but standards such as ISO/IEC 12207 represent processes that establish a lifecycle for software, and provide a mode for the development, acquisition, and configuration of software systems.

Benefits of the SDLC Process

The intent of a SDLC process it to help produce a product that is cost-efficient, effective, and of high quality. Once an application is created, the SDLC maps the proper deployment and decommissioning of the software once it becomes a legacy. The SDLC methodology usually contains the following stages: Analysis (requirements and design), construction, testing, release, and maintenance (response). Veracode makes it possible to integrate automated security testing into the SDLC process through use of its cloud based platform.


Phases of the Software Development Life Cycle


  • SDLC starts with the analysis and definition phases, where the purpose of the software or system should be determined, the goals of what it needs to accomplish need to be established, and a set of definite requirements can be developed.
  • During the software construction or development stage, the actual engineering and writing of the application is done. The software is designed and produced, while attempting to accomplish all of the requirements that were set forth within the previous stage.
  • Next, in the software development life cycle is the testing phase. Code produced during construction should be tested using static and dynamic analysis, as well as manual penetration testing to ensure that the application is not easily exploitable to hackers, which could result in a critical security breach. The advantage of using Veracode during this stage is that by using state of the art binary analysis (no source code required), the security posture of applications can be verified without requiring the use of any additional hardware, software, or personnel.





Once the software is deemed secure enough for use, it can be implemented in a beta environment to test real-world usability, and then pushed a full release where it enters the maintenance phase. The maintenance stage allows the application to be adjusted to organizational, systemic, and utilization changes.

SDLC Implementation

There are two different types of SDLC that can be used: waterfall and agile. The major difference between the two is that the waterfall process is more traditional and begins with a well thought out plan and defined set of requirements whereas agile SDLC begins with less stringent guidelines and then makes adjustments as needed throughout the process. Agile development is known for its ability to quickly translate an application that is in development to a full 



Sunday, September 14, 2014

MVC, MVVM, MVP Design Patterns

There are Several Design Patterns in .Net, But basically we have to understand the MVC, MVVM, MVP Design Patterns.

MVC Pattern

MVC stands for Model-View-Controller. It is a software design pattern which was introduced in 1970s. Also, MVC pattern forces a separation of concerns, it means domain model and controller logic are decoupled from user interface (view). As a result maintenance and testing of the application become simpler and easier.

MVC design pattern splits an application into three main aspects: Model, View and Controller


Ff649643.des_MVC_Fig01(en-us,PandP.10).gif


-  Model

The Model represents a set of classes that describe the business logic i.e. business model as well as data access operations i.e. data model. It also defines business rules for data means how the data can be changed and manipulated.

-  View

The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the controller as the result. This also transforms the model(s) into UI.

-  Controller

The Controller is responsible to process incoming requests. It receives input from users via the View, then process the user's data with the help of Model and passing the results back to the View. Typically, it acts as the coordinator between the View and the Model.


MVP Pattern

This pattern is similar to MVC pattern in which controller has been replaced by the presenter. This design pattern splits an application into three main aspects: Model, View and Presenter.

Ff649571.354b3e51-0023-46a2-9288-4cf5744594f0(en-us,PandP.10).png

-  Model

The Model represents a set of classes that describes the business logic and data. It also defines business rules for data means how the data can be changed and manipulated.


-  View

The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the presenter as the result. This also transforms the model(s) into UI.

 - Presenter

The Presenter is responsible for handling all UI events on behalf of the view. This receive input from users via the View, then process the user's data with the help of Model and passing the results back to the View. Unlike view and controller, view and presenter are completely decoupled from each other’s and communicate to each other’s by an interface.

Also, presenter does not manage the incoming request traffic as controller.

This pattern is commonly used with ASP.NET Web Forms applications which require to create automated unit tests for their code-behind pages. This is also used with windows forms.


MVVM Pattern

MVVM stands for Model-View-View Model. This pattern supports two-way data binding between view and View model. This enables automatic propagation of changes, within the state of view model to the View. Typically, the view model uses the observer pattern to notify changes in the view model to model.

The MVVM classes and their interactions


-  Model

The Model represents a set of classes that describes the business logic and data. It also defines business rules for data means how the data can be changed and manipulated.

-  View

The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the controller as the result. This also transforms the model(s) into UI.

-  View Model

The View Model is responsible for exposing methods, commands, and other properties that helps to maintain the state of the view, manipulate the model as the result of actions on the view, and trigger events in the view itself.
This pattern is commonly used by the WPF, Silverlight, Caliburn, nRoute etc.

Do you think this Article useful for you, need to know more, then you can subscribe this blog.

Please your valuable feedback about this blog to dotnetcircle@gmail.com

Thursday, September 11, 2014

Main Difference between Java and .Net



Features of C# Absent in Java


  • C# includes more primitive types and the functionality to catch arithmetic exceptions.

  • Includes a large number of notational conveniences over Java, many of which, such as operator overloading and user-defined casts, are already familiar to the large community of C++ programmers.
  • Event handling is a "first class citizen"—it is part of the language itself.
  • Allows the definition of "structs", which are similar to classes but may be allocated on the stack (unlike instances of classes in C# and Java).
  • C# implements properties as part of the language syntax.
  • C# allows switch statements to operate on strings.
  • C# allows anonymous methods providing closure functionality.
  • C# allows iterator that employs co-routines via a functional-style yield keyword.
  • C# has support for output parameters, aiding in the return of multiple values, a feature shared by C++ and SQL.
  • C# has the ability to alias namespaces.
  • C# has "Explicit Member Implementation" which allows a class to specifically implement methods of an interface, separate from its own class methods. This allows it also to implement two different interfaces which happen to have a method of the same name. The methods of an interface do not need to be public; they can be made to be accessible only via that interface.
  • C# provides integration with COM.
  • Following the example of C and C++, C# allows call by reference for primitive and reference types.


Features of Java Absent in C#


  • Java's strictfp keyword guarantees that the result of floating point operations remain the same across platforms.
  • Java supports checked exceptions for better enforcement of error trapping and handling.
For More Information :

Tuesday, September 9, 2014

Trigger in WPF

Triggers



Triggers is used in style to perform action on change any property value or event fires. Triggers create visual effects on controls. By using Triggers we can change the appearance of Framework Elements.


Types of Triggers :




01. Property Trigger

This trigger gets active when UIElements property value changes. The below Trigger is created on Button. It will set Opacity to 0.5 when Buttons IsPressed property change.

    <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
    <Style.Triggers>
    <Trigger Property="IsPressed" Value="True">
    <Setter Property="Opacity" Value="0.5" />
    </Trigger>
    <Trigger Property="IsEnabled" Value="False">
    <Setter Property="Foreground" Value="Red" />
    </Trigger>
    </Style.Triggers>
    </Style>

02. Event Trigger

This trigger gets active when RoutedEvent of FrameworkElement raise. Event Trigger is generally used to perform some animation on control like as colorAnimation, doubleAnumation using KeyFrame etc.

The below trigger is used to animate/change the color property (SolidColorBrush, LinearGradientBrush ) of the UIElement at defined time duration.

    <Border Name="border1" Width="100" Height="30"
    BorderBrush="Black" BorderThickness="1">
    <Border.Background>
    <SolidColorBrush x:Name="MyBorder" Color="LightBlue" />
    </Border.Background>
    <Border.Triggers>
    <EventTrigger RoutedEvent="Mouse.MouseEnter">
    <BeginStoryboard>
    <Storyboard>
    <ColorAnimation Duration="0:0:1"
    Storyboard.TargetName="MyBorder"
    Storyboard.TargetProperty="Color"
    To="Gray" />
    </Storyboard>
    </BeginStoryboard>
    </EventTrigger>
    </Border.Triggers&
    gt;
    </Border>

03. Data Trigger

This trigger gets active when Binding Data matches specified condition. Below DataTrigger is created on Picture property of binding data. Setter objects of the DataTrigger describes property values to apply when binding data match the condition. Picture is Byte[] property of the class. If Picture is null then DataTrigger applies on image to set image source to noImage.png, otherwise it will set image source from picture.

Same as if picture is null, applies TextBlock value to "No Image Availalbe" and foreground color to red otherwise sets default value from data.

    <DataTemplate>
    <Grid Margin="0 5 0 0">
    <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Image x:Name="viewImage"
    Grid.Row="0" Width="100"
    Height="60" HorizontalAlignment="Center"
    Source="{Binding Picture}" Stretch="Fill" />
    <TextBlock x:Name="viewText"
    Grid.Row="1" Margin="0 5 0 0"
    HorizontalAlignment="Center"
    FontWeight="Black" Foreground="Green"
    Text="{Binding Title}" />
    </Grid>
    <DataTemplate.Triggers>
    <DataTrigger Binding="{Binding Path=Picture}" Value="{x:Null}">
    <Setter TargetName="viewImage" Property="Source" Value="/Images/noImage.png" />
    <Setter TargetName="viewText" Property="Text" Value="No Image Available" />
    <Setter TargetName="viewText" Property="Foreground" Value="Red" />
    </DataTrigger>
    </DataTemplate.Triggers>
    </DataTemplate>


Summary:

What do you think about this Article? Please give your feedback to dotnetcircle@gmail.com

Subscribe to this blog for Interesting Concepts to Know in .Net.

Friday, September 5, 2014

Thursday, September 4, 2014

Basics on WCF Service

Introduction



What is WCF?



WCF is a service Oriented programming in .net framework 3.0 and plus, which provide unique platform for all type of Communications in .net for distributed Applications.

It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF.

Basic Bare Bones of WCF

Endpoints (ABC terms).


- Address

- Binding

- Contract

All the WCF communications are take place through end point. End point consists of three components.(i.e ABC)

Address:

   Basically URL, specifies where this WCF service is hosted .Client will use this url to connect to the service.

         e.g http://localhost:8071/MyService/Calculator.svc.

Binding:

   Binding will describes how client will communicate with service. There are different protocols available for the WCF to communicate to the Client. You can mention the protocol type based on your requirements.

In My service I used Basic Http Service protocol for communication.i.e wsHttpBinding

Contract: 

   Collection of operation that specifies what the endpoint will communicate with outside world. Usually name of the Interface will be mentioned in the Contract, so the client application will be aware of the operations which are exposed to the client. Each operation is a simple exchange pattern such as one-way, duplex and request/reply.

In My Service Contract is” Service1 “.

Exchange pattern is” request/reply”;

2. Service Contract: Service contracts describe the operation that service can provide

3. Operation Contract: Attribute Which is used to define the Method as part of Service.


Demo of the Calculator Example.
Step By Step Procedure

1   Creating WCF Service

2   Consuming WCF Service in Web Application using VS 2008.

3   Creating WCF Client.

Creating WCF Service.
Steps:

1.    Open  VS 2008 > Projects > Select C#  >  WCF  > WCF Service Library.

2.    Type name of  the service file as u need. In this ex.MyWCFSolution. then click OK.

3.    New Window will open with one Class.cs and Interface .cs File which can be seen in Solution Explore.

4.    Add the Namespace System.ServiceModel and  also add  Reference in Solution Explore.

5.    Type the Code in Interface file and class file as shown below.

Code in Interface(EX: IService1.cs)

[ServiceContract]
    public interface IService1
    {
        [OperationContract]
       int add(int a,int b);

        [OperationContract]
       int Sub(int a, int b);

        [OperationContract]
        int Mul(int a, int b);

        [OperationContract]
        int Div(int a, int b);

        // TODO: Add your service operations here
    }



Code in Class file(EX: Service1.cs)

public class Service1 : IService1
    {
     
        int IService1.add(int a, int b)
        {
            return (a + b);
        }

        int IService1.Sub(int a, int b)
        {
            if (a >= b)
            {
                return (a - b);
            }
            else
            {
                return (b - a);
            }
        }
     
     
        public int Mul(int a, int b)
        {
            return (a * b);
        }

        public int Div(int a, int b)
        {
            if(a>=b)
                try { return (a / b); }
                catch
                { return 0; }
            else
                return (b / a);
        }
    }

Consuming WCF Service in Web Application.

Steps:

1. Create web Application as shown in attachment please download the File.



2. After Creating Desing of the Calculator web application the add reference System.ServiceModel namespace into web application in Solution Explore.

3. Add the WCF Service in visual studio by right click on Reference and select Add service Reference

4. Give the Service hosted Address and click on Go button and select the service which u created I mean in Ex service1.

5. Give the namespace: Name as Myservice and  the click OK .

1.    Creating WCF Client.

In Order to call the Methods (services from WCFService) we need to Create the porxy WCF Client.

Once service is consumed in Application, WCF Client is Created, So Using the name of the Client Name we can call the methods in out applications

EX. In  Our WCF Service we have 4 methods (add, sub, mul, div).

2.   TO get the WCF client name Double click on Service i.e Myservice and take the copy of the Client name.

The fwindow will open in that u take the copy.

3.   Paste the Client Name in Default.cs File get the following code then create the instance of the client as show in below code. Using this porxy client u can call the services of the WCF service as shown in below code.

4.   On paste u get MY.Myservice.Service1Client

5.  Code to be Right in Default.cs in web application(EX:Calculator)

namespace Calculator
{
    public partial class _Default : System.Web.UI.Page
    {
     
        Calculator.Myservice.Service1Client Client = new Calculator.Myservice.Service1Client();
//Creating proxy client instance “Client”
        int a, b;
        protected void Page_Load(object sender, EventArgs e)
        {
         
            Response.Write("MY Calculator");

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);

            int Addition = Client.add(10,20);
            txtResult.Text = Addition.ToString();
        }

        protected void btnsub_Click(object sender, EventArgs e)
        {
            a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
int Addition = Client.Sub(10, 20);
            txtResult.Text = Addition.ToString();

        }

        protected void btnmul_Click(object sender, EventArgs e)
        {
a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
            int Addition = Client.Mul(10, 20);
            txtResult.Text = Addition.ToString();
        }

        protected void btndiv_Click(object sender, EventArgs e)
        {
            a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
int Addition = Client.Div(10, 20);
            txtResult.Text = Addition.ToString();

        }
    }
}

Testing the application and using WCF services.

1.  Run the WCF service First.(Ex:MyWCFsolution)

2.  Run the wev Application(EX: Calculator)(download the attachements)



Conclusion

Hope this article makes Sense of  basic Idea about WCF. Thank you.