data driven wpf and silverlight applications
Post on 18-Oct-2014
3.187 views
DESCRIPTION
TRANSCRIPT
Data Driven WPF and Silverlight ApplicationsData Driven WPF and Silverlight Applications
Dave AllenISV Application ArchitectDeveloper and Platform GroupMicrosoft UK
AgendaAgenda
Windows Presentation FoundationSilverlightEntity FrameworkWCF Data ServicesSilverlight & WCF Data ServicesSilverlight & WCF RIA Services
The Windows Client PlatformThe Windows Client Platform
WPFSilverlight
Silverlight Mobile
.NET
XAMLDesktopWeb
Mobile
Windows Presentation FoundationWindows Presentation Foundation
Now in it’s forth release: 3.0, 3.5, 3.5 SP1, 4.0Highly stable platform for rich client applicationsMany bug fixes and supplemental featuresPerformance optimizations – especially cold start-up
Some mixed messages on it’s initial releaseWinForms is dead, no further development – not true!Backtrack – WPF isn’t really suitable for LOB – was true!Tooling not good enough for RAD of LOB apps – was true!
WPF is moving into mainstream LOBWPF 4.0 primary goal is LOB applicationsWPF Toolkit still available for supplemental features
Silverlight (subset of WPF)Silverlight (subset of WPF)
Now in it’s forth release: 1.0, 2.0, 3.0, 4.0Platform for Rich Internet Applications (RIAs)Was originally a browser plug-in – still it’s primary useCross-browser, cross-platforms, cross-deviceIncludes .NET Runtime for C# and VB.NET
Some key featuresFrom SL3 will now run out-of-browserPrimary development platform for Windows Phone 7Includes rich networking stackIntegrates with HTML DOMSupports Isolated StorageSupports Safe File Open Dialog
The user experienceThe user experience
Primary features of WPF/SilverlightPrimary features of WPF/Silverlight
Vector based graphics, resolution-independent DPI Composition engine – allows nesting of all controlsUnified programming model for 2D, 3D, and MediaDeclarative programming model with XAMLHigh degree of control over stylingPowerful text engine and rendering Support different types of layoutAdvanced animation techniquesBuilt-in support for data bindingInterop with COM components
WPF/Silverlight programming modelWPF/Silverlight programming model
Declarative programming with XAMLUI and code easy to separate1:1 matching between XAML and codeEasily toolable
<Button Width="100"> OK <Button.Background> LightBlue </Button.Background></Button>
XAMLButton b1 = new Button();b1.Content = "OK";b1.Background = new SolidColorBrush(Colors.LightBlue);b1.Width = 100;
C#Dim b1 As New Buttonb1.Content = "OK"b1.Background = New _ SolidColorBrush(Colors.LightBlue)b1.Width = 100
VB.NET
DemoDemoWPF applications
WPF/Silverlight UI componentsWPF/Silverlight UI components
ControlsLayout (Canvas, Border, StackPanel, Grid)Button, Calendar, Checkbox, Datagrid, DateTimePicker, GridSplitter, HyperLink, Image, ListBox, MediaElement, MultiScaleImage, Popup, Radio, Slider, TextBox, TextBlock, Toggle, Tooltip, etc.User Control – aggregation of existing controls
StylingReuse of UI properties across multiple controls
TemplatingOverride the way a control displays itselfData templating for customization of how data is displayed
Data BindingAllows binding of DataContext to a DataSource
DemoDemoXAML and Silverlight anatomy
Silverlight behind the scenesSilverlight behind the scenes
Background processing on separate threadSystem.ComponentModel.BackgroundWorker
Web ServicesSOAP 1.1 BP + Duplex, JSON, REST, RSS
SocketsOnly ports 4502-4534 are supported
Isolated StoragePer user, per application or per site/domain1Mb quota is the default, can be changed
File Open DialogAllows user to choose file, access the file stream, upload
DemoDemoBehind the scenes
Silverlight 3/4 FeaturesSilverlight 3/4 Features
Silverlight 360+ new controls addedData FormsDeep LinkingMulti-page ApplicationElement to Element bindingOut of Browser
Silverlight 4Printing supportRich text support32 new languages + right to left supportElevated privileges and COM automation (OOB)Webcam/Mic support
WPF and Silverlight applicationsWPF and Silverlight applications
The paradigm shiftWPF not a natural fit for a WinForms, VB6, MFC developer that has grown up on GDI/User32XAML mark-up language more familiar to Web developersVisual Studio 2010 and Expression Blend generate XAML
WPF/Silverlight/XBAP – too many options?Decision is much simpler than you thinkIf you develop and deploy WinForms applications today
WPF is the natural choice – full fidelity .NETIf you develop WinForms applications and deployment is a problem, then XBAP could be the answer
Restricted to browser sandbox – full fidelity .NETAlso consider Out of Browser Silverlight
If you target the browser today and are moving to RIASilverlight is the natural next step
ADO.NET Entity FrameworkADO.NET Entity Framework
Another data access technology!?!Not designed to replace what has gone beforeAddresses the OOP versus Relational problem
OOP very well establishedRelational have been around even longerBridging the gap has mostly been a manual taskSome 3rd party solutions, core problem remains
Objects != Relational DataFundamental problem is that relational data and objects in a programming language are NOT the same!
They have different semantics, languages, etc.But both are still needed in most applications
ADO.NET Entity FrameworkADO.NET Entity Framework
Entity Data ModelModels Entities and relationships between those EntitiesHow does it bridge the gap between OOP and Relational
Common type systemInheritanceComplex types
EDM is scoped to just modeling design of application data
Entity FrameworkProvides services for consuming an EDM
Object ServicesEntity Client (EntityConnection, EntityDataReader, etc.)Entity SQLLINQ To EntitiesProvider model for 3rd party databases
Entity Data ModelEntity Data Model
Application modelMapped to a persistence store
Comprised of three layers:Conceptual (CSDL)Mapping (MSL)Storage (SSDL)
Database agnosticNot compiled
Embed as a resourceStore externally
Conceptual
Mapping
Storage
Entity Data Model
DemoDemoEntity Data Model
Entity FrameworkEntity Framework
EDM consumption options:Entity Client
Entity SQLObject Services
Entity SQLLINQ To Entities
Entity Framework – Service StackEntity Framework – Service Stack
LINQ To Entities
Object Services
Entity SQL
Entity Client
ADO.NET Provider
Entity ClientEntity Client
Familiar ADO.NET object model:EntityCommandEntityConnectionEntityDataReaderEntity ParameterEntityTransaction
Text-based resultsRead-onlyUses Entity SQL
Entity SQLEntity SQL
• SQL-like query language• Targets conceptual model• Database agnostic
T-SQL
Entity SQL
Object ServicesObject Services
Object materialized queriesObjectContextObjectQuery<T>
Built on top of Entity ClientTwo query options:
Entity SQLLINQ
Runtime services:Unit of workIdentity trackingEager/explicit loading
Entity Framework featuresEntity Framework features
Many to many relationshipsJoin tables ignored by designer in EDMSide-effect, relationships cannot contain dataLINQ supports this via the aggregate functions
InheritanceAllows Entities to be specializedMaps to CLR inheritanceFully supported in queries3 types of inheritance
Table per typeTable per hierarchyTable per concrete type
Entity Framework features (2)Entity Framework features (2)
Entity splittingSingle entity split across multiple tables, something you may do with very large tables
Stored proceduresMost asked question about EFFully supported for CUD, map CUD functions to SPsMainly supported for queries, but doesn’t support composable queries, dynamic SQL within SPs
No metadata available at design-timeWorking against principles of EFDon’t use EF if you do this
Consider using TVF instead of SPs
Entity Framework 4.0 new featuresEntity Framework 4.0 new features
Model-first developmentAutomatic pluralizationForeign keys in modelsPOCO class supportLazy loadingT4 Code GenerationTemplate customizationIObjectSetVirtual SaveChangesObjectStateManager control
Self-tracking entitiesSQL generation improvementsMore LINQ operator supportLINQ extensibilityExecuteStoreQueryExecuteStoreCommandSPROC import improvementsModel defined functionsWPF designer integration
DemoDemoEntity Framework
Data Service over HTTPData Service over HTTP
HTML + JavaScript
Data (XML, etc)
DLL + XAML
Data (XML, etc) Data (XML, etc)
Mashup UI
Data Feeds
AJAX Applicatio
ns
Silverlight Applicatio
ns
Online Services
Mashups
Data Services todayData Services today
Web Service (ASMX, WCF)
1) GetCustomer(int id)
2) GetCustomers()
3) GetCustomers(string orderBy)
4) GetCustomers(string orderBy, string sortDirection)
5) GetCustomers(string orderBy, string sortDirection, int offset, int count)
6) GetCustomers(string orderBy, string sortDirection, int offset, int count, string filter, string filterValue)
WCF Data ServicesWCF Data Services
Data publishing service using a RESTful interfaceJust uses HTTP
Therefore is able to use existing authentication mechanisms, and other infrastructure components such as caching and proxies
Uniform URL SyntaxEvery piece of information is addressablePredictable and flexible URL syntax
Multiple representationsATOMJSONPOX
WCF Data Services (2)WCF Data Services (2)
Exposes an object model (not a database) over the web
Entity Data Model – WCF DS designed to work with EDMLINQ To SQL model, read-onlyCustom IQueryable<T> provider
Operation semantics, mapping of HTTP verbs for CRUD operations
GET – retrieve resourcePOST – create a resourcePUT – update a resourceDELETE – delete a resource
URL ConventionsURL Conventions
Addressing entities and sets
Presentation options
Entity-set /Product
Single Entity /Product(324)
Member access /Product(324)/Name
Link traversal /ProductSubcategory(2)/Product
Deep access /ProductSubcategory(2)/Product(789)/Name
Raw value access /Product(324)/Name/$value
Sorting /Product?$orderby=Name
Filtering /Product?$filter=Color%20eq%20'Black'
Paging /Product?4top=10$skip=30
Inline expansion /ProductSubcategory?$expand=Product
FiltersFilters
Logical operatorsand, or , asc, desc, eq, ne, true, false, gt, ge, lt, le, not, null
Arithmetic operatorsadd, sub, div, mul, mod
String functionsendswith, indexof, replace, startswith, tolower, toupper, trim, substring, substringof, concat, length
Date functionsyear, month, day, hour, minute, second
Math functionsround, floor, ceiling
Type functionsIs, Cast
DemoDemoWCF Data Services
Securing and Customizing Data ServicesSecuring and Customizing Data Services
VisibilityControl visibility per containerRead, Query, and Write options
AuthenticationIntegrates with the hosting environmentASP.NET, WCF, or Custom authentication module
InterceptorsExecute before HTTP GET/PUT/POST/DELETEEnable validation, custom row-level securityMaintain the REST interface
Service operationsAllow you to inject methods into URI if you need to
ClientsClients
Data Service
Silverlight ClientSilverlight Client
DataServiceHTTP
DataModel
DataServiceContext
ObjectModel
ServerClient
DemoDemoSilverlight WCF Data Services Client