Microsoft .NetMicrosoft .Net
Microsoft .Net OverviewMicrosoft .Net Overview
 Microsoft .Net is a technology or a strategy that is used to createMicrosoft .Net is a technology or a strategy that is used to create
web as well as windows applications with rich user interface.web as well as windows applications with rich user interface.
 Microsoft .Net supports multiple programming languages in aMicrosoft .Net supports multiple programming languages in a
manner that allows language interoperability, whereby eachmanner that allows language interoperability, whereby each
language can utilize code written in other languages.language can utilize code written in other languages.
 Microsoft .Net uses the .Net framework to create, build and deployMicrosoft .Net uses the .Net framework to create, build and deploy
Microsoft Applications.Microsoft Applications.
 Microsoft provides visual Studio.NET environment to develop theMicrosoft provides visual Studio.NET environment to develop the
.net applications..net applications.
.Net Framework Architecture.Net Framework Architecture
.Net Framework Class Library.Net Framework Class Library
 The .NET Framework class library is aThe .NET Framework class library is a
collection of reusable types that tightlycollection of reusable types that tightly
integrate with the common languageintegrate with the common language
runtime.runtime.
 The class library is object oriented,The class library is object oriented,
providing types which users can reuse toproviding types which users can reuse to
write the managed code.write the managed code.
 Built using classes arranged acrossBuilt using classes arranged across
logical hierarchical namespaceslogical hierarchical namespaces
 The class library Works with all CLRThe class library Works with all CLR
languageslanguages
 It enables to accomplish a range ofIt enables to accomplish a range of
common programming tasks, includingcommon programming tasks, including
tasks such as string management, datatasks such as string management, data
collection, database connectivity, and filecollection, database connectivity, and file
access.access.
Unified Classes
Web Classes (ASP.NET)
XML Classes
System Classes
Drawing Classes
Windows FormsData (ADO.NET)
Controls, Caching, Security, Session, Configuration etc
Collections, Diagnostics, Globalization, IO, Security,
Threading Serialization, Reflection, Messaging etc
ADO, SQL,Types etc
Drawing, Imaging, Text, etc
Design, Cmpnt Model etc
XSLT, Path, Serialization etc
ADO. NetADO. Net
 ADO. Net stands for ActiveX DataADO. Net stands for ActiveX Data
Objects .Net.Objects .Net.
 ADO.NET is the primary data accessADO.NET is the primary data access
API for the .NET Framework.API for the .NET Framework.
 ADO.NET provides consistent accessADO.NET provides consistent access
to data sources such as SQL Server, asto data sources such as SQL Server, as
well as data sources exposed throughwell as data sources exposed through
OLE DB and XML.OLE DB and XML.
 It provides the classes that are used toIt provides the classes that are used to
develop database applications withdevelop database applications with
.NET languages..NET languages.
 The ADO.NET components have beenThe ADO.NET components have been
designed to factor data access fromdesigned to factor data access from
data manipulation. There are twodata manipulation. There are two
central components of ADO.NET thatcentral components of ADO.NET that
accomplish this: the Dataset, andaccomplish this: the Dataset, and
the .NET Framework data provider,the .NET Framework data provider,
which is a set of components includingwhich is a set of components including
the Connection, Command, Datathe Connection, Command, Data
Reader, and Data Adapter objects.Reader, and Data Adapter objects.
Features of .Net 3.5Features of .Net 3.5
 Language Integrated Query (LINQ)Language Integrated Query (LINQ)
 Anonymous TypesAnonymous Types
 Extension MethodsExtension Methods
 Ajax IntegrationAjax Integration
 Listview controlListview control
 Datapager controlDatapager control
 LinqDataSource controlLinqDataSource control
 Partial MethodsPartial Methods
LINQLINQ
LINQ ProvidersLINQ Providers

LINQ to ObjectsLINQ to Objects

LINQ to SQLLINQ to SQL

LINQ to XMLLINQ to XML

LINQ to DatasetLINQ to Dataset
LINQ to Objects –LINQ to Objects –
used to query in memory collectionsused to query in memory collections
Ex:Ex: string[] tools = { “one", “two", “three", “four"};string[] tools = { “one", “two", “three", “four"};
var list = from t in tools select t;var list = from t in tools select t;
StringBuilder sb = new StringBuilder();StringBuilder sb = new StringBuilder();
foreach (string s in list) { sb.Append(s +foreach (string s in list) { sb.Append(s +
Environment.NewLine); }Environment.NewLine); }
MessageBox.Show(sb.ToString(), "Tools");MessageBox.Show(sb.ToString(), "Tools");
LINQLINQ
LINQ to SQL –LINQ to SQL –
allows developers to write queries in .NET language to retrieve and manipulateallows developers to write queries in .NET language to retrieve and manipulate
data from SQL Server Database.data from SQL Server Database.
Ex:Ex: Add Linq to SQL class to the project.Add Linq to SQL class to the project.
LINQLINQ
From the Server Explorer drag the required Data objects on to the Northwind.dbmlFrom the Server Explorer drag the required Data objects on to the Northwind.dbml
designer surface.designer surface.
LINQLINQ
using (NorthwindDataContext context = newusing (NorthwindDataContext context = new
NorthwindDataContext())NorthwindDataContext())
{{
var customers = from c in context.Customersvar customers = from c in context.Customers
where c.customerid >10 && c.customerid<100where c.customerid >10 && c.customerid<100
orderby c.customeridorderby c.customerid
select c;select c;
gridViewCustomers.DataSource = customers;gridViewCustomers.DataSource = customers;
gridViewCustomers.DataBind();gridViewCustomers.DataBind();
}}
LINQLINQ
LINQ to XML –LINQ to XML –
provides an in-memory XML programming interface that leverages
the .NET Language-Integrated Query (LINQ) Framework.
var result = from e invar result = from e in
XElement.Load ("winners.xml") .ElementsXElement.Load ("winners.xml") .Elements
("winner")("winner")
select new Winnerselect new Winner
{ Name = (string) e.Element ("Name"),{ Name = (string) e.Element ("Name"),
Country = (string) e.Element ("Country"),Country = (string) e.Element ("Country"),
Year = (int) e.Element ("Year") };Year = (int) e.Element ("Year") };
foreach (Winner w in result)foreach (Winner w in result)
{ Console.WriteLine("{0} {1}, {2}", w.Year, w.Name,{ Console.WriteLine("{0} {1}, {2}", w.Year, w.Name,
w.Country); }w.Country); }
LINQLINQ
LINQ to Dataset –LINQ to Dataset –
Language-Integrated Query (LINQ) queries work on data sources thatLanguage-Integrated Query (LINQ) queries work on data sources that
implement the IENUMERABLE<T> interface or the IQueryable interface. Theimplement the IENUMERABLE<T> interface or the IQueryable interface. The
DataTable class does not implement either interface, AsEnumerable method must beDataTable class does not implement either interface, AsEnumerable method must be
called to use the DataTable as a source in the From clause of a LINQ query.called to use the DataTable as a source in the From clause of a LINQ query.
DataSet ds = new DataSet();DataSet ds = new DataSet();
FillDataSet(ds);FillDataSet(ds);
DataTable orders = ds.Tables ["SalesOrderHeader"];DataTable orders = ds.Tables ["SalesOrderHeader"];
var query = from order in orders.AsEnumerable() wherevar query = from order in orders.AsEnumerable() where
order.Field <bool>("OnlineOrderFlag") == trueorder.Field <bool>("OnlineOrderFlag") == true
select new { SalesOrderID = order.Field<int>("SalesOrderID"),select new { SalesOrderID = order.Field<int>("SalesOrderID"),
OrderDate = order.Field <DateTime>("OrderDate"),OrderDate = order.Field <DateTime>("OrderDate"), SalesOrderNumber =SalesOrderNumber =
order.Field<string>("SalesOrderNumber") };order.Field<string>("SalesOrderNumber") };
foreach (var onlineOrder in query)foreach (var onlineOrder in query)
{ Console.WriteLine ("Order ID: {0} Order date: {1:d} Order number:{ Console.WriteLine ("Order ID: {0} Order date: {1:d} Order number: {2}",{2}",
onlineOrder.SalesOrderID, onlineOrder.OrderDate,onlineOrder.SalesOrderID, onlineOrder.OrderDate,
onlineOrder.SalesOrderNumber); }onlineOrder.SalesOrderNumber); }
Anonymous TypesAnonymous Types
Anonymous Types provide a convenient way to encapsulate a set ofAnonymous Types provide a convenient way to encapsulate a set of
read only properties into a single object without having to explicitlyread only properties into a single object without having to explicitly
define a type.define a type.
var x=new { Company=“Infotech”, client=“IHS”}var x=new { Company=“Infotech”, client=“IHS”}
Extension MethodsExtension Methods
 Extension methods are defined as static methods but are called by using instanceExtension methods are defined as static methods but are called by using instance
method syntax.method syntax.
 Their first parameter specifies which type the method operates on, and the parameterTheir first parameter specifies which type the method operates on, and the parameter
is preceded by the “this” modifier.is preceded by the “this” modifier.
 Extension methods are only in scope when the namespace that contains theExtension methods are only in scope when the namespace that contains the
Extension method is explicitly imported into the source code with a using directive.Extension method is explicitly imported into the source code with a using directive.
public static class EMClasspublic static class EMClass
{{
public static int ToInt32Ext(this string s)public static int ToInt32Ext(this string s)
{ return Int32.Parse(s); }{ return Int32.Parse(s); }
}}
class Programclass Program
{{
static void Main(string[] args)static void Main(string[] args)
{{
string s = "9";string s = "9";
int i = s.ToInt32Ext();int i = s.ToInt32Ext();
Console.WriteLine(i);Console.WriteLine(i);
}}
}}
ListView and DataPager controlsListView and DataPager controls
 ASP.NET ListView control enables to bind to data items that are returnedASP.NET ListView control enables to bind to data items that are returned
from a data source and display them.from a data source and display them.
 ListView control displays data in a format that is defined by using templatesListView control displays data in a format that is defined by using templates
and styles.and styles.
 Unlike Repeater and DataList controls supports Editing, Paging and SortingUnlike Repeater and DataList controls supports Editing, Paging and Sorting
the data.the data.
 Supports different types of templates like Layout Template, Item Template,Supports different types of templates like Layout Template, Item Template,
Group Template, ItemSeperator Template etc.Group Template, ItemSeperator Template etc.
 For Paging functionality Data Pager control is used.For Paging functionality Data Pager control is used.
 The DataPager control supports built in Paging UI.The DataPager control supports built in Paging UI.
 DataPager control can be present in the Layout Template of the list view.DataPager control can be present in the Layout Template of the list view.
 OtherwiseOtherwise PagedcontrolID property of the DataPager control is set toPagedcontrolID property of the DataPager control is set to
the ID of the ListView control.the ID of the ListView control.
LinqDataSource controlLinqDataSource control
 The LinqDataSource Control enables developers to declarativelyThe LinqDataSource Control enables developers to declaratively
bind data to ASP.NET data controls by executing LINQ queriesbind data to ASP.NET data controls by executing LINQ queries
against the data stores.against the data stores.
 The LinqDataSource control uses LINQ to SQL to automaticallyThe LinqDataSource control uses LINQ to SQL to automatically
generate the data commands.generate the data commands.
 The LINQDataSource Control can also be used to execute storedThe LINQDataSource Control can also be used to execute stored
procedures and complex queries.procedures and complex queries.
<asp:LinqDataSource ID="LinqDataSource1" runat="server"<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="DataClassesDataContext"ContextTypeName="DataClassesDataContext"
Select="new (VendorId, VendorFName, VendorLName,Select="new (VendorId, VendorFName, VendorLName,
VendorCity, VendorState, VendorCountry, PostedDate,VendorCity, VendorState, VendorCountry, PostedDate,
VendorDescription)"VendorDescription)"
TableName="Vendors"TableName="Vendors"
EnableDelete="true"EnableDelete="true"
EnableInsert="true"EnableInsert="true"
EnableUpdate="true">EnableUpdate="true">
</asp:LinqDataSource></asp:LinqDataSource>
Partial MethodsPartial Methods
 Partial Methods are defined in Partial classes.Partial Methods are defined in Partial classes.
 Declared using the keyword Partial.Declared using the keyword Partial.
 Should be always Private and Void.Should be always Private and Void.
 Will have implementation only at one place.Will have implementation only at one place.
 If Partial method is not implemented then compiler will ignore theIf Partial method is not implemented then compiler will ignore the
calls made to the partial method.calls made to the partial method.
 Ex. of auto generated partial methods are methods that areEx. of auto generated partial methods are methods that are
generated when Linq to Sql class is generated.generated when Linq to Sql class is generated.
Windows Presentation FoundationWindows Presentation Foundation
 TheThe Windows Presentation FoundationWindows Presentation Foundation is Microsoft's next generation UIis Microsoft's next generation UI
framework to create applications with a rich user experience. It is part offramework to create applications with a rich user experience. It is part of
the .NET framework 3.0 and higher.the .NET framework 3.0 and higher.
 WPF combines application UIs, 2D graphics, 3D graphics, documents andWPF combines application UIs, 2D graphics, 3D graphics, documents and
multimedia into one single framework.multimedia into one single framework.
 WPF attempts to provide a consistent programming model for buildingWPF attempts to provide a consistent programming model for building
applications and provides a clear separation between the user interface andapplications and provides a clear separation between the user interface and
the business logic.the business logic.
 The appearance is generally specified in the Extensible Application MarkupThe appearance is generally specified in the Extensible Application Markup
Language (XAML), the behavior is implemented in a managed programmingLanguage (XAML), the behavior is implemented in a managed programming
language like C# .language like C# .
 These two parts are tied together by data binding, events and commands.These two parts are tied together by data binding, events and commands.
 Separates design from code allowing graphics designers and coders to workSeparates design from code allowing graphics designers and coders to work
together on the same projecttogether on the same project
 WPF applications can be deployed as standalone desktop programs, orWPF applications can be deployed as standalone desktop programs, or
hosted as XAML Browser applications (XBAPS).hosted as XAML Browser applications (XBAPS).
WPF ArchitectureWPF Architecture
Features of WPFFeatures of WPF
Application Model:Application Model:
• Every application is inherited from WPF standardEvery application is inherited from WPF standard ApplicationApplication class.class.
• AnAn ApplicationApplication object can be created with either XAML, via theobject can be created with either XAML, via the
ApplicationApplication element, or code, using theelement, or code, using the ApplicationApplication class.class.
• This class provides standard methods such asThis class provides standard methods such as RunRun, which starts the, which starts the
application, andapplication, and ShutdownShutdown, which terminates it., which terminates it.
Layout and Controls:Layout and Controls:
• WPF application usesWPF application uses panelspanels for layout. Stack Panel, Grid Panel,for layout. Stack Panel, Grid Panel,
Canvas are the panels that are used mostly.Canvas are the panels that are used mostly.
• Each panel can contain children, includingEach panel can contain children, including controlscontrols such as buttonssuch as buttons
and text boxes, and other panels.and text boxes, and other panels.
Styles and Templates:Styles and Templates:
• Using XAMLUsing XAML StyleStyle property of the element, style for an element canproperty of the element, style for an element can
be defined.be defined.
• WPF also supports the use of templates (Data templates, ControlWPF also supports the use of templates (Data templates, Control
templates).templates).
Graphics:Graphics:
 For 2D graphics, WPF defines a group of shapes that applications can useFor 2D graphics, WPF defines a group of shapes that applications can use
to create images. They are: Line, Ellipse, Rectangle, Polygon, Polyline,to create images. They are: Line, Ellipse, Rectangle, Polygon, Polyline,
Path.Path.
 To display 3D graphics in WPF, an application uses the Viewport3D control.To display 3D graphics in WPF, an application uses the Viewport3D control.
 A Viewport3D control can be used anywhere in a WPF interface, allowingA Viewport3D control can be used anywhere in a WPF interface, allowing
3D graphics to appear wherever they're needed.3D graphics to appear wherever they're needed.
Data Binding:Data Binding:
WPF has a built-in set of data services to enable application developers toWPF has a built-in set of data services to enable application developers to
bind and manipulate data within applications. There exists support for threebind and manipulate data within applications. There exists support for three
types of data binding:types of data binding:
• one time: where the client ignores updates on the server.one time: where the client ignores updates on the server.
• one way: where the client has read-only access to data.one way: where the client has read-only access to data.
• two way: where client can read from and write data to the server.two way: where client can read from and write data to the server.
 LINQ queries, specifically LINQ to XML, can also act as data sources forLINQ queries, specifically LINQ to XML, can also act as data sources for
data binding.data binding.
 Binding of data has no bearing on its presentation. WPF provides dataBinding of data has no bearing on its presentation. WPF provides data
templates to control presentation of data.templates to control presentation of data.
What is SOAWhat is SOA
 A loosely coupled architecture designed toA loosely coupled architecture designed to
meet the business needs of themeet the business needs of the
organizationorganization
 SOA represents business functions asSOA represents business functions as
shared, reusable serviceshared, reusable service
SOASOA
 Web servicesWeb services
 WCF servicesWCF services
What is WCFWhat is WCF
 Provides software services on machines,Provides software services on machines,
networks, and across the internetnetworks, and across the internet
 Unified programming model for all of theseUnified programming model for all of these
 Supported natively on Windows VistaSupported natively on Windows Vista

Requires installation on XPRequires installation on XP
 Not available on other platformsNot available on other platforms

Mono?Mono?

DotGnu?DotGnu?

Mac OSX ?Mac OSX ?
Unified Programming ModelUnified Programming Model
Interop
with other
platforms
ASMX
Attribute-
Based
Programming
Enterprise
Services
WS-*
Protocol
Support
WSE
Message-
Oriented
Programming
System.Messaging
Extensibility
Location
transparency
.NET
Remoting
WCF High Level ViewWCF High Level View
Service
WSDL
CBA
CBA
A
Address(A)
Where?
C
Contract(C)
What?
B
Binding(B)
How?
Client
ABC
Be Be
Behavior(Be)
Local Only Details
Building Options : Standard BindingsBuilding Options : Standard Bindings
Interop.Interop.
SecuritySecurity
SessionSession
TransactionsTransactions
DuplexDuplex
BasicHttpBindingBasicHttpBinding BP 1.1BP 1.1 TT
WsHttpBindingWsHttpBinding WSWS T | ST | S XX XX
WsDualHttpBindingWsDualHttpBinding WSWS T | ST | S XX XX XX
NetTcpBindingNetTcpBinding .NET.NET T | ST | S XX XX XX
NetNamedPipesBindingNetNamedPipesBinding .NET.NET T | ST | S XX XX XX
NetMsmqBindingNetMsmqBinding .NET.NET T | ST | S XX XX**
MsmqIntegrationBindingMsmqIntegrationBinding .NET.NET TT
NetPeerTcpBindingNetPeerTcpBinding .NET.NET T | ST | S XX
WCF Design PrincipalsWCF Design Principals
 Boundaries are explicitBoundaries are explicit

No attempt to hide communicationNo attempt to hide communication
 Services are autonomousServices are autonomous

Deployed, managed, and versioned independentlyDeployed, managed, and versioned independently
 Services share contracts and schemas, notServices share contracts and schemas, not
typestypes

Contracts define behavior, schemas define dataContracts define behavior, schemas define data
 Compatibility is policy-basedCompatibility is policy-based

Policy supports separation of behavior from accessPolicy supports separation of behavior from access
constraintsconstraints
Essential Pieces of WCFEssential Pieces of WCF
 Contracts forContracts for servicesservices,, datadata, and, and messagesmessages

A contract is simply an interface declarationA contract is simply an interface declaration
 Service, Data, and Message definitionsService, Data, and Message definitions

Class implementations of the contractsClass implementations of the contracts
 Configurations defined programmatically or declarativelyConfigurations defined programmatically or declaratively

.Net class instances versus config files..Net class instances versus config files.
 A host process (can be self hosted)A host process (can be self hosted)

IIS, Windows Executable, Windows Service, or WASIIS, Windows Executable, Windows Service, or WAS
 .Net Framework (3.5) Classes provide support for all of.Net Framework (3.5) Classes provide support for all of
the above.the above.
Look and Feel of WCFLook and Feel of WCF
 Convergence of programming modelsConvergence of programming models

Just like web servicesJust like web services

Similar to .Net RemotingSimilar to .Net Remoting

Sockets on steroidsSockets on steroids

Hosting for local, network, and webHosting for local, network, and web
 Communication modelsCommunication models

Remote Procedure Call (RPC) with optional dataRemote Procedure Call (RPC) with optional data
modelsmodels

Message passingMessage passing

One way, request and (callback) reply, synchronousOne way, request and (callback) reply, synchronous
callcall
WCF ArchitectureWCF Architecture
WCF Service FilesWCF Service Files
 IService.csIService.cs

Interface(s) that define a service, data, or message contractInterface(s) that define a service, data, or message contract
 Service.csService.cs

Implement the service’s functionalityImplement the service’s functionality
 Service.svcService.svc

Markup file (with one line) used for services hosted in IISMarkup file (with one line) used for services hosted in IIS
 Configuration files that declare service attributes,Configuration files that declare service attributes,
endpoints, and policyendpoints, and policy

App.config (self hosted) contains service model markupApp.config (self hosted) contains service model markup

Web.config (hosted in IIS) has web server policy markup plusWeb.config (hosted in IIS) has web server policy markup plus
service model markup, as in App.configservice model markup, as in App.config
Service BehaviorsService Behaviors
 Instancing:Instancing:

SingletonSingleton: one instance for all clients: one instance for all clients

Per callPer call: one instance per service call: one instance per service call

Private sessionPrivate session: one instance per client session: one instance per client session

Shared sessionShared session: one instance per session shared: one instance per session shared
between clientsbetween clients
 Concurrency models for instances:Concurrency models for instances:

SingleSingle: one thread at a time accesses instance: one thread at a time accesses instance

MultipleMultiple: more than one thread may enter instance: more than one thread may enter instance

ReentrantReentrant: threads make recursive calls without: threads make recursive calls without
deadlockdeadlock
Thank YouThank You

.Net 3.5

  • 1.
  • 2.
    Microsoft .Net OverviewMicrosoft.Net Overview  Microsoft .Net is a technology or a strategy that is used to createMicrosoft .Net is a technology or a strategy that is used to create web as well as windows applications with rich user interface.web as well as windows applications with rich user interface.  Microsoft .Net supports multiple programming languages in aMicrosoft .Net supports multiple programming languages in a manner that allows language interoperability, whereby eachmanner that allows language interoperability, whereby each language can utilize code written in other languages.language can utilize code written in other languages.  Microsoft .Net uses the .Net framework to create, build and deployMicrosoft .Net uses the .Net framework to create, build and deploy Microsoft Applications.Microsoft Applications.  Microsoft provides visual Studio.NET environment to develop theMicrosoft provides visual Studio.NET environment to develop the .net applications..net applications.
  • 3.
    .Net Framework Architecture.NetFramework Architecture
  • 4.
    .Net Framework ClassLibrary.Net Framework Class Library  The .NET Framework class library is aThe .NET Framework class library is a collection of reusable types that tightlycollection of reusable types that tightly integrate with the common languageintegrate with the common language runtime.runtime.  The class library is object oriented,The class library is object oriented, providing types which users can reuse toproviding types which users can reuse to write the managed code.write the managed code.  Built using classes arranged acrossBuilt using classes arranged across logical hierarchical namespaceslogical hierarchical namespaces  The class library Works with all CLRThe class library Works with all CLR languageslanguages  It enables to accomplish a range ofIt enables to accomplish a range of common programming tasks, includingcommon programming tasks, including tasks such as string management, datatasks such as string management, data collection, database connectivity, and filecollection, database connectivity, and file access.access. Unified Classes Web Classes (ASP.NET) XML Classes System Classes Drawing Classes Windows FormsData (ADO.NET) Controls, Caching, Security, Session, Configuration etc Collections, Diagnostics, Globalization, IO, Security, Threading Serialization, Reflection, Messaging etc ADO, SQL,Types etc Drawing, Imaging, Text, etc Design, Cmpnt Model etc XSLT, Path, Serialization etc
  • 5.
    ADO. NetADO. Net ADO. Net stands for ActiveX DataADO. Net stands for ActiveX Data Objects .Net.Objects .Net.  ADO.NET is the primary data accessADO.NET is the primary data access API for the .NET Framework.API for the .NET Framework.  ADO.NET provides consistent accessADO.NET provides consistent access to data sources such as SQL Server, asto data sources such as SQL Server, as well as data sources exposed throughwell as data sources exposed through OLE DB and XML.OLE DB and XML.  It provides the classes that are used toIt provides the classes that are used to develop database applications withdevelop database applications with .NET languages..NET languages.  The ADO.NET components have beenThe ADO.NET components have been designed to factor data access fromdesigned to factor data access from data manipulation. There are twodata manipulation. There are two central components of ADO.NET thatcentral components of ADO.NET that accomplish this: the Dataset, andaccomplish this: the Dataset, and the .NET Framework data provider,the .NET Framework data provider, which is a set of components includingwhich is a set of components including the Connection, Command, Datathe Connection, Command, Data Reader, and Data Adapter objects.Reader, and Data Adapter objects.
  • 6.
    Features of .Net3.5Features of .Net 3.5  Language Integrated Query (LINQ)Language Integrated Query (LINQ)  Anonymous TypesAnonymous Types  Extension MethodsExtension Methods  Ajax IntegrationAjax Integration  Listview controlListview control  Datapager controlDatapager control  LinqDataSource controlLinqDataSource control  Partial MethodsPartial Methods
  • 7.
    LINQLINQ LINQ ProvidersLINQ Providers  LINQto ObjectsLINQ to Objects  LINQ to SQLLINQ to SQL  LINQ to XMLLINQ to XML  LINQ to DatasetLINQ to Dataset LINQ to Objects –LINQ to Objects – used to query in memory collectionsused to query in memory collections Ex:Ex: string[] tools = { “one", “two", “three", “four"};string[] tools = { “one", “two", “three", “four"}; var list = from t in tools select t;var list = from t in tools select t; StringBuilder sb = new StringBuilder();StringBuilder sb = new StringBuilder(); foreach (string s in list) { sb.Append(s +foreach (string s in list) { sb.Append(s + Environment.NewLine); }Environment.NewLine); } MessageBox.Show(sb.ToString(), "Tools");MessageBox.Show(sb.ToString(), "Tools");
  • 8.
    LINQLINQ LINQ to SQL–LINQ to SQL – allows developers to write queries in .NET language to retrieve and manipulateallows developers to write queries in .NET language to retrieve and manipulate data from SQL Server Database.data from SQL Server Database. Ex:Ex: Add Linq to SQL class to the project.Add Linq to SQL class to the project.
  • 9.
    LINQLINQ From the ServerExplorer drag the required Data objects on to the Northwind.dbmlFrom the Server Explorer drag the required Data objects on to the Northwind.dbml designer surface.designer surface.
  • 10.
    LINQLINQ using (NorthwindDataContext context= newusing (NorthwindDataContext context = new NorthwindDataContext())NorthwindDataContext()) {{ var customers = from c in context.Customersvar customers = from c in context.Customers where c.customerid >10 && c.customerid<100where c.customerid >10 && c.customerid<100 orderby c.customeridorderby c.customerid select c;select c; gridViewCustomers.DataSource = customers;gridViewCustomers.DataSource = customers; gridViewCustomers.DataBind();gridViewCustomers.DataBind(); }}
  • 11.
    LINQLINQ LINQ to XML–LINQ to XML – provides an in-memory XML programming interface that leverages the .NET Language-Integrated Query (LINQ) Framework. var result = from e invar result = from e in XElement.Load ("winners.xml") .ElementsXElement.Load ("winners.xml") .Elements ("winner")("winner") select new Winnerselect new Winner { Name = (string) e.Element ("Name"),{ Name = (string) e.Element ("Name"), Country = (string) e.Element ("Country"),Country = (string) e.Element ("Country"), Year = (int) e.Element ("Year") };Year = (int) e.Element ("Year") }; foreach (Winner w in result)foreach (Winner w in result) { Console.WriteLine("{0} {1}, {2}", w.Year, w.Name,{ Console.WriteLine("{0} {1}, {2}", w.Year, w.Name, w.Country); }w.Country); }
  • 12.
    LINQLINQ LINQ to Dataset–LINQ to Dataset – Language-Integrated Query (LINQ) queries work on data sources thatLanguage-Integrated Query (LINQ) queries work on data sources that implement the IENUMERABLE<T> interface or the IQueryable interface. Theimplement the IENUMERABLE<T> interface or the IQueryable interface. The DataTable class does not implement either interface, AsEnumerable method must beDataTable class does not implement either interface, AsEnumerable method must be called to use the DataTable as a source in the From clause of a LINQ query.called to use the DataTable as a source in the From clause of a LINQ query. DataSet ds = new DataSet();DataSet ds = new DataSet(); FillDataSet(ds);FillDataSet(ds); DataTable orders = ds.Tables ["SalesOrderHeader"];DataTable orders = ds.Tables ["SalesOrderHeader"]; var query = from order in orders.AsEnumerable() wherevar query = from order in orders.AsEnumerable() where order.Field <bool>("OnlineOrderFlag") == trueorder.Field <bool>("OnlineOrderFlag") == true select new { SalesOrderID = order.Field<int>("SalesOrderID"),select new { SalesOrderID = order.Field<int>("SalesOrderID"), OrderDate = order.Field <DateTime>("OrderDate"),OrderDate = order.Field <DateTime>("OrderDate"), SalesOrderNumber =SalesOrderNumber = order.Field<string>("SalesOrderNumber") };order.Field<string>("SalesOrderNumber") }; foreach (var onlineOrder in query)foreach (var onlineOrder in query) { Console.WriteLine ("Order ID: {0} Order date: {1:d} Order number:{ Console.WriteLine ("Order ID: {0} Order date: {1:d} Order number: {2}",{2}", onlineOrder.SalesOrderID, onlineOrder.OrderDate,onlineOrder.SalesOrderID, onlineOrder.OrderDate, onlineOrder.SalesOrderNumber); }onlineOrder.SalesOrderNumber); }
  • 13.
    Anonymous TypesAnonymous Types AnonymousTypes provide a convenient way to encapsulate a set ofAnonymous Types provide a convenient way to encapsulate a set of read only properties into a single object without having to explicitlyread only properties into a single object without having to explicitly define a type.define a type. var x=new { Company=“Infotech”, client=“IHS”}var x=new { Company=“Infotech”, client=“IHS”}
  • 14.
    Extension MethodsExtension Methods Extension methods are defined as static methods but are called by using instanceExtension methods are defined as static methods but are called by using instance method syntax.method syntax.  Their first parameter specifies which type the method operates on, and the parameterTheir first parameter specifies which type the method operates on, and the parameter is preceded by the “this” modifier.is preceded by the “this” modifier.  Extension methods are only in scope when the namespace that contains theExtension methods are only in scope when the namespace that contains the Extension method is explicitly imported into the source code with a using directive.Extension method is explicitly imported into the source code with a using directive. public static class EMClasspublic static class EMClass {{ public static int ToInt32Ext(this string s)public static int ToInt32Ext(this string s) { return Int32.Parse(s); }{ return Int32.Parse(s); } }} class Programclass Program {{ static void Main(string[] args)static void Main(string[] args) {{ string s = "9";string s = "9"; int i = s.ToInt32Ext();int i = s.ToInt32Ext(); Console.WriteLine(i);Console.WriteLine(i); }} }}
  • 15.
    ListView and DataPagercontrolsListView and DataPager controls  ASP.NET ListView control enables to bind to data items that are returnedASP.NET ListView control enables to bind to data items that are returned from a data source and display them.from a data source and display them.  ListView control displays data in a format that is defined by using templatesListView control displays data in a format that is defined by using templates and styles.and styles.  Unlike Repeater and DataList controls supports Editing, Paging and SortingUnlike Repeater and DataList controls supports Editing, Paging and Sorting the data.the data.  Supports different types of templates like Layout Template, Item Template,Supports different types of templates like Layout Template, Item Template, Group Template, ItemSeperator Template etc.Group Template, ItemSeperator Template etc.  For Paging functionality Data Pager control is used.For Paging functionality Data Pager control is used.  The DataPager control supports built in Paging UI.The DataPager control supports built in Paging UI.  DataPager control can be present in the Layout Template of the list view.DataPager control can be present in the Layout Template of the list view.  OtherwiseOtherwise PagedcontrolID property of the DataPager control is set toPagedcontrolID property of the DataPager control is set to the ID of the ListView control.the ID of the ListView control.
  • 16.
    LinqDataSource controlLinqDataSource control The LinqDataSource Control enables developers to declarativelyThe LinqDataSource Control enables developers to declaratively bind data to ASP.NET data controls by executing LINQ queriesbind data to ASP.NET data controls by executing LINQ queries against the data stores.against the data stores.  The LinqDataSource control uses LINQ to SQL to automaticallyThe LinqDataSource control uses LINQ to SQL to automatically generate the data commands.generate the data commands.  The LINQDataSource Control can also be used to execute storedThe LINQDataSource Control can also be used to execute stored procedures and complex queries.procedures and complex queries. <asp:LinqDataSource ID="LinqDataSource1" runat="server"<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="DataClassesDataContext"ContextTypeName="DataClassesDataContext" Select="new (VendorId, VendorFName, VendorLName,Select="new (VendorId, VendorFName, VendorLName, VendorCity, VendorState, VendorCountry, PostedDate,VendorCity, VendorState, VendorCountry, PostedDate, VendorDescription)"VendorDescription)" TableName="Vendors"TableName="Vendors" EnableDelete="true"EnableDelete="true" EnableInsert="true"EnableInsert="true" EnableUpdate="true">EnableUpdate="true"> </asp:LinqDataSource></asp:LinqDataSource>
  • 17.
    Partial MethodsPartial Methods Partial Methods are defined in Partial classes.Partial Methods are defined in Partial classes.  Declared using the keyword Partial.Declared using the keyword Partial.  Should be always Private and Void.Should be always Private and Void.  Will have implementation only at one place.Will have implementation only at one place.  If Partial method is not implemented then compiler will ignore theIf Partial method is not implemented then compiler will ignore the calls made to the partial method.calls made to the partial method.  Ex. of auto generated partial methods are methods that areEx. of auto generated partial methods are methods that are generated when Linq to Sql class is generated.generated when Linq to Sql class is generated.
  • 18.
    Windows Presentation FoundationWindowsPresentation Foundation  TheThe Windows Presentation FoundationWindows Presentation Foundation is Microsoft's next generation UIis Microsoft's next generation UI framework to create applications with a rich user experience. It is part offramework to create applications with a rich user experience. It is part of the .NET framework 3.0 and higher.the .NET framework 3.0 and higher.  WPF combines application UIs, 2D graphics, 3D graphics, documents andWPF combines application UIs, 2D graphics, 3D graphics, documents and multimedia into one single framework.multimedia into one single framework.  WPF attempts to provide a consistent programming model for buildingWPF attempts to provide a consistent programming model for building applications and provides a clear separation between the user interface andapplications and provides a clear separation between the user interface and the business logic.the business logic.  The appearance is generally specified in the Extensible Application MarkupThe appearance is generally specified in the Extensible Application Markup Language (XAML), the behavior is implemented in a managed programmingLanguage (XAML), the behavior is implemented in a managed programming language like C# .language like C# .  These two parts are tied together by data binding, events and commands.These two parts are tied together by data binding, events and commands.  Separates design from code allowing graphics designers and coders to workSeparates design from code allowing graphics designers and coders to work together on the same projecttogether on the same project  WPF applications can be deployed as standalone desktop programs, orWPF applications can be deployed as standalone desktop programs, or hosted as XAML Browser applications (XBAPS).hosted as XAML Browser applications (XBAPS).
  • 19.
  • 20.
    Features of WPFFeaturesof WPF Application Model:Application Model: • Every application is inherited from WPF standardEvery application is inherited from WPF standard ApplicationApplication class.class. • AnAn ApplicationApplication object can be created with either XAML, via theobject can be created with either XAML, via the ApplicationApplication element, or code, using theelement, or code, using the ApplicationApplication class.class. • This class provides standard methods such asThis class provides standard methods such as RunRun, which starts the, which starts the application, andapplication, and ShutdownShutdown, which terminates it., which terminates it. Layout and Controls:Layout and Controls: • WPF application usesWPF application uses panelspanels for layout. Stack Panel, Grid Panel,for layout. Stack Panel, Grid Panel, Canvas are the panels that are used mostly.Canvas are the panels that are used mostly. • Each panel can contain children, includingEach panel can contain children, including controlscontrols such as buttonssuch as buttons and text boxes, and other panels.and text boxes, and other panels. Styles and Templates:Styles and Templates: • Using XAMLUsing XAML StyleStyle property of the element, style for an element canproperty of the element, style for an element can be defined.be defined. • WPF also supports the use of templates (Data templates, ControlWPF also supports the use of templates (Data templates, Control templates).templates).
  • 21.
    Graphics:Graphics:  For 2Dgraphics, WPF defines a group of shapes that applications can useFor 2D graphics, WPF defines a group of shapes that applications can use to create images. They are: Line, Ellipse, Rectangle, Polygon, Polyline,to create images. They are: Line, Ellipse, Rectangle, Polygon, Polyline, Path.Path.  To display 3D graphics in WPF, an application uses the Viewport3D control.To display 3D graphics in WPF, an application uses the Viewport3D control.  A Viewport3D control can be used anywhere in a WPF interface, allowingA Viewport3D control can be used anywhere in a WPF interface, allowing 3D graphics to appear wherever they're needed.3D graphics to appear wherever they're needed. Data Binding:Data Binding: WPF has a built-in set of data services to enable application developers toWPF has a built-in set of data services to enable application developers to bind and manipulate data within applications. There exists support for threebind and manipulate data within applications. There exists support for three types of data binding:types of data binding: • one time: where the client ignores updates on the server.one time: where the client ignores updates on the server. • one way: where the client has read-only access to data.one way: where the client has read-only access to data. • two way: where client can read from and write data to the server.two way: where client can read from and write data to the server.  LINQ queries, specifically LINQ to XML, can also act as data sources forLINQ queries, specifically LINQ to XML, can also act as data sources for data binding.data binding.  Binding of data has no bearing on its presentation. WPF provides dataBinding of data has no bearing on its presentation. WPF provides data templates to control presentation of data.templates to control presentation of data.
  • 22.
    What is SOAWhatis SOA  A loosely coupled architecture designed toA loosely coupled architecture designed to meet the business needs of themeet the business needs of the organizationorganization  SOA represents business functions asSOA represents business functions as shared, reusable serviceshared, reusable service
  • 23.
    SOASOA  Web servicesWebservices  WCF servicesWCF services
  • 24.
    What is WCFWhatis WCF  Provides software services on machines,Provides software services on machines, networks, and across the internetnetworks, and across the internet  Unified programming model for all of theseUnified programming model for all of these  Supported natively on Windows VistaSupported natively on Windows Vista  Requires installation on XPRequires installation on XP  Not available on other platformsNot available on other platforms  Mono?Mono?  DotGnu?DotGnu?  Mac OSX ?Mac OSX ?
  • 25.
    Unified Programming ModelUnifiedProgramming Model Interop with other platforms ASMX Attribute- Based Programming Enterprise Services WS-* Protocol Support WSE Message- Oriented Programming System.Messaging Extensibility Location transparency .NET Remoting
  • 26.
    WCF High LevelViewWCF High Level View Service WSDL CBA CBA A Address(A) Where? C Contract(C) What? B Binding(B) How? Client ABC Be Be Behavior(Be) Local Only Details
  • 27.
    Building Options :Standard BindingsBuilding Options : Standard Bindings Interop.Interop. SecuritySecurity SessionSession TransactionsTransactions DuplexDuplex BasicHttpBindingBasicHttpBinding BP 1.1BP 1.1 TT WsHttpBindingWsHttpBinding WSWS T | ST | S XX XX WsDualHttpBindingWsDualHttpBinding WSWS T | ST | S XX XX XX NetTcpBindingNetTcpBinding .NET.NET T | ST | S XX XX XX NetNamedPipesBindingNetNamedPipesBinding .NET.NET T | ST | S XX XX XX NetMsmqBindingNetMsmqBinding .NET.NET T | ST | S XX XX** MsmqIntegrationBindingMsmqIntegrationBinding .NET.NET TT NetPeerTcpBindingNetPeerTcpBinding .NET.NET T | ST | S XX
  • 28.
    WCF Design PrincipalsWCFDesign Principals  Boundaries are explicitBoundaries are explicit  No attempt to hide communicationNo attempt to hide communication  Services are autonomousServices are autonomous  Deployed, managed, and versioned independentlyDeployed, managed, and versioned independently  Services share contracts and schemas, notServices share contracts and schemas, not typestypes  Contracts define behavior, schemas define dataContracts define behavior, schemas define data  Compatibility is policy-basedCompatibility is policy-based  Policy supports separation of behavior from accessPolicy supports separation of behavior from access constraintsconstraints
  • 29.
    Essential Pieces ofWCFEssential Pieces of WCF  Contracts forContracts for servicesservices,, datadata, and, and messagesmessages  A contract is simply an interface declarationA contract is simply an interface declaration  Service, Data, and Message definitionsService, Data, and Message definitions  Class implementations of the contractsClass implementations of the contracts  Configurations defined programmatically or declarativelyConfigurations defined programmatically or declaratively  .Net class instances versus config files..Net class instances versus config files.  A host process (can be self hosted)A host process (can be self hosted)  IIS, Windows Executable, Windows Service, or WASIIS, Windows Executable, Windows Service, or WAS  .Net Framework (3.5) Classes provide support for all of.Net Framework (3.5) Classes provide support for all of the above.the above.
  • 30.
    Look and Feelof WCFLook and Feel of WCF  Convergence of programming modelsConvergence of programming models  Just like web servicesJust like web services  Similar to .Net RemotingSimilar to .Net Remoting  Sockets on steroidsSockets on steroids  Hosting for local, network, and webHosting for local, network, and web  Communication modelsCommunication models  Remote Procedure Call (RPC) with optional dataRemote Procedure Call (RPC) with optional data modelsmodels  Message passingMessage passing  One way, request and (callback) reply, synchronousOne way, request and (callback) reply, synchronous callcall
  • 31.
  • 32.
    WCF Service FilesWCFService Files  IService.csIService.cs  Interface(s) that define a service, data, or message contractInterface(s) that define a service, data, or message contract  Service.csService.cs  Implement the service’s functionalityImplement the service’s functionality  Service.svcService.svc  Markup file (with one line) used for services hosted in IISMarkup file (with one line) used for services hosted in IIS  Configuration files that declare service attributes,Configuration files that declare service attributes, endpoints, and policyendpoints, and policy  App.config (self hosted) contains service model markupApp.config (self hosted) contains service model markup  Web.config (hosted in IIS) has web server policy markup plusWeb.config (hosted in IIS) has web server policy markup plus service model markup, as in App.configservice model markup, as in App.config
  • 33.
    Service BehaviorsService Behaviors Instancing:Instancing:  SingletonSingleton: one instance for all clients: one instance for all clients  Per callPer call: one instance per service call: one instance per service call  Private sessionPrivate session: one instance per client session: one instance per client session  Shared sessionShared session: one instance per session shared: one instance per session shared between clientsbetween clients  Concurrency models for instances:Concurrency models for instances:  SingleSingle: one thread at a time accesses instance: one thread at a time accesses instance  MultipleMultiple: more than one thread may enter instance: more than one thread may enter instance  ReentrantReentrant: threads make recursive calls without: threads make recursive calls without deadlockdeadlock
  • 34.