SlideShare a Scribd company logo
Building an enterprise application with Silverlight and NHibernateGill CleerenMicrosoft Regional Director/MVP ASP.NETVisugUsergroup lead - Ordinawww.snowball.beBart WullemsMCT, MCPDApplication Architect Ordinabartwullems.blogspot.com
AgendaBuilding the foundationCQRSODataNHibernateBuilding the front-end in SilverlightMVVMWhat is MVVM?Why and why notThe parts of MVVMImplementing MVVM principlesDemoFinding your VM using MEFCommandingCommunication between VMs
Scenario: Planning your vacation with NHibernate and Silverlight
Building the foundation
Bye bye 3-tier
What is CQRS?
CQS DefinedBertrand Meyer (via Wikipedia)“Command Query Separation”“every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, asking a question should not change the answer.”
CQRS definedMeyer: Separate command methods that change state from query methods that read state.Greg Young: Separate command messages that change state from query messages that read state.Can have significant architectural implications
Welcome CQRS
QueriesSimple Query LayerSimple views or sprocs or selects from denormalized tablesSimple DTOs, no mapping neededDon’t go through the Domain Model, as it pollutes itViewModel per query perhapsWhy should the data come across 5 layers through 3 model transformations to populate a screen? (Udi)Synchronous, no messaging needed
CommandsCommands capture intent, DTOs don’tCustomerDTOvsCustomerChangedAddressCommandHandler per commandCan be validated outside of domain entitiesThis is why domain entities are never invalid, commands that would produce invalid state are rejected
CommandsSeparate Data ModificationMake preferredChange addressA generic DTO could do these things, of course, but after the fact, how do you know what actually happened?UI ImplicationsGrid-like screens don’t workCommands require specific intent
How do we implementthis?
Implement the  query model usingodata
OData.org
A RESTful Interface for DataJust HTTPData as resources, HTTP methods to act on itLeverage caching, proxies, authentication, …Uniform URL syntaxEvery piece of information is addressablePredictable and flexible URL syntaxMultiple representationsUse regular HTTP content-type negotiationAtomPub, JSON
Model and Operation SemanticsUnderlying data modelEntity Data ModelEntities ResourcesAssociationsLinksOperation semanticsMapping of HTTP methodsGET  Retrieve resourcePOST Create resourcePUT  Update resourceDELETE Delete resource
WCF (Data) ServicesWCF Data Services	WCF ServicesRESTAtomPubODataSOAPWS-SecurityWS-*
WCF Data ServicesHTTPData Services RuntimeReflection Provider.NET Classes [+ LINQ provider]Data Source(IQueryable)
oData and SilverlightAccessing Data ServicesSilverlight ClientHttp stack still an optionData Services Client more usable as it knows the details of the data service interfaceFeaturesFull abstraction on top of the service – no need to deal with HTTP, serialization, etcData as objects with automatic change trackingLINQ for queriesData-binding friendly interfacesWork same-domain and cross-domain
CQRS and ODataOData21
DemoUsingOData to implement the query part of CQRS22
Implement the  domain model usingnhibernate
NHibernateFull-featured ORM solutionOpen sourceBased on Java’s Hibernate frameworkUses XML(by default) to map tables/columns to objects/properties
NHibernate API
NHibernateQuickstartCreate hibernate.cfg.xml or use app.configvarcfg = newConfiguration(); cfg.Configure();varsf = cfg.BuildSessionFactory();using(var s = sf.OpenSession())using(vartx = s.BeginTransaction()) {   var c = s.Get<Customer>(42);tx.Commit();}
WhyNHibernate?EntityFrameworkGreatforRapidApplicationDevelopmentFalls short forEnterpriseApplicationDevelopmentNHibernate has	More maturityMore flexibilityBetterextensibility
Building an enterprise app in silverlight 4 and NHibernate
CQRS and NHibernateNHibernateNHibernate29
Convention over ConfigurationFluentNHibernatehttp://fluentnhibernate.orgReplacesXML mappingbyfluentmappingXML configurationbyfluentconfigurationAdvantagesType safetyRemovestedious XML mappingsIntuitive interfaceConventions
AutomaticSession managementDataContext per RequestIServiceBusRequest 1Session 1DBSession 2Request 2
DemoUsing NHibernate to implement the domain part of CQRS32
Building the front-end in Silverlight
What is MVVM?
Understanding MVVMMVVM :is an architectural pattern created by John Gossman from WPF teamis a variation of MVC patternis similar to Martin Fowler’s PresentationModel patternworks because of Silverlight data Binding & commandingis typically used in WPF/SL-applications to leverage the power of XAML, so that Devs and Designers can work together easier35
Understanding MVVM
Why and why not MVVM?
Why MVVMBetter SoC (Seperation of Concerns)More maintainableModel never needs to be changed to support changes to the viewViewModel rarely needs to be changed to support changes to the viewMore testable ViewModelis easier to unit test than code-behind or event driven codeEliminates the need to do code behind which leaves the UI all in XAML 38
Why MVVMBecause the framework (SL & WPF) have the power to support itDatabinding/DataContextIncreases the "Blendability" of your view
Why not MVVMLack of standardization so everyone has own favorMessage to community is not clear!!For simple UI, M-V-VM can be overkill
Too much code neededINotifyPropertyChangedCommands40
The parts of MVVM
What we all do…All UI code in code-behindViewXAMLData ModelCode-BehindEvent Handlers
The MVVM wayViewXAMLCode-BehindChange notificationData-binding and commandsView ModelData ModelState + Operations
The parts of MVVMView knows ViewModel
ViewModel knows Models
But not vice versa.ViewViewModelModel44
The ViewThe viewrepresents the user interface that the user will see.can be a user control or Data Templateshouldn't contain any logic that you want to testshould be kept as simple as possible.45
The ViewModelAn abstraction of View
Connector between View and Model
Make VM as testable as possible46
The ModelCan be Data Model, DTO, POCO, auto-generated proxy of domain class and UI Model based on how you want to have the separation between Domain Service and Presentation Layer
No reference to ViewModel47
Where to start?BING (or google is fine as well )MVVM Light ToolkitPrismCaliburn48
DemoLet’s take a look at an MVVM implementation49
Implementing MVVM principles
View model base classImplements INotifyPropertyChangedContains base code for all VMs to re-use51
DemoBaseViewModel52
Which comes first...2 options: View firstViewModel first53
ViewFirstBased on XAML mostlyThe View has a relationship to its ViewModel (usually through data binding).DataContext={Binding ...}Available at design time (Blend support)54View<UserControl.DataContext>    <dive:PageViewModel /></UserControl.DataContext>
ViewModel FirstThe ViewModel creates the view usually through an IoCcontaineror MEF	55View Modelpublic MyViewModel(IMyViewmyView){myView.Model = this;}
How to implement this?Locator patternImplemented through a class that contains all VMs as static propertiesAn instance is then made available as ResourceAll Views can bind, no code needed in View Clean way Not good since all VMs need to be known upfrontProperty for each available VMDifficult if application is MDI-like (more than one instance available)56

More Related Content

What's hot (20)

PPTX
ASP .NET MVC Introduction & Guidelines
Dev Raj Gautam
 
PPTX
ASP.NET MVC 5 - EF 6 - VS2015
Hossein Zahed
 
PPTX
Architecting ASP.NET MVC Applications
Gunnar Peipman
 
PPTX
Asp.net mvc 5 course module 1 overview
Sergey Seletsky
 
PPTX
Getting started with MVC 5 and Visual Studio 2013
Thomas Robbins
 
PDF
ASP.NET MVC 3
Buu Nguyen
 
PPTX
ASP.NET MVC Performance
rudib
 
PDF
ColdFusion 11 New Features
Mindfire Solutions
 
PPTX
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
PPT
MVC ppt presentation
Bhavin Shah
 
PPT
MVC Pattern. Flex implementation of MVC
Anton Krasnoshchok
 
PPT
Introduction to ASP.NET MVC 1.0
Shiju Varghese
 
PPTX
Head first asp.net mvc 2.0 rtt
Lanvige Jiang
 
PPTX
MVC - Introduction
Sudhakar Sharma
 
PPTX
MVC 6 Introduction
Sudhakar Sharma
 
PPTX
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Aaron Jacobson
 
PPTX
What's new in asp.net mvc 4
Simone Chiaretta
 
PDF
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
PPTX
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
PDF
Setup ColdFusion application using fusebox mvc architecture
Mindfire Solutions
 
ASP .NET MVC Introduction & Guidelines
Dev Raj Gautam
 
ASP.NET MVC 5 - EF 6 - VS2015
Hossein Zahed
 
Architecting ASP.NET MVC Applications
Gunnar Peipman
 
Asp.net mvc 5 course module 1 overview
Sergey Seletsky
 
Getting started with MVC 5 and Visual Studio 2013
Thomas Robbins
 
ASP.NET MVC 3
Buu Nguyen
 
ASP.NET MVC Performance
rudib
 
ColdFusion 11 New Features
Mindfire Solutions
 
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
MVC ppt presentation
Bhavin Shah
 
MVC Pattern. Flex implementation of MVC
Anton Krasnoshchok
 
Introduction to ASP.NET MVC 1.0
Shiju Varghese
 
Head first asp.net mvc 2.0 rtt
Lanvige Jiang
 
MVC - Introduction
Sudhakar Sharma
 
MVC 6 Introduction
Sudhakar Sharma
 
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Aaron Jacobson
 
What's new in asp.net mvc 4
Simone Chiaretta
 
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
Setup ColdFusion application using fusebox mvc architecture
Mindfire Solutions
 

Viewers also liked (7)

PPTX
Unit Testing MVVM in Silverlight
Timmy Kokke
 
PPTX
Real-world Model-View-ViewModel for WPF
Paul Stovell
 
PPTX
MVVM+MEF in Silvelight - W 2010ebday
Ricardo Fiel
 
PPTX
Adopting MVVM
John Cumming
 
PPTX
NHibernate for .NET
Guo Albert
 
PDF
NHibernate (The ORM For .NET Platform)
Samnang Chhun
 
PDF
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 
Unit Testing MVVM in Silverlight
Timmy Kokke
 
Real-world Model-View-ViewModel for WPF
Paul Stovell
 
MVVM+MEF in Silvelight - W 2010ebday
Ricardo Fiel
 
Adopting MVVM
John Cumming
 
NHibernate for .NET
Guo Albert
 
NHibernate (The ORM For .NET Platform)
Samnang Chhun
 
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 
Ad

Similar to Building an enterprise app in silverlight 4 and NHibernate (20)

PPTX
Advanced MVVM in Windows 8
Gill Cleeren
 
PPTX
Applied MVVM in Windows 8 apps: not your typical MVVM session!
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
PDF
MvvmCross Seminar
Xamarin
 
PDF
MvvmCross Introduction
Stuart Lodge
 
PPTX
Mike Taulty MIX10 Silverlight Frameworks and Patterns
ukdpe
 
PPTX
Introduction to MVVM Framework
Honeyson Joseph
 
PDF
MVVM Light Toolkit Works Great, Less Complicated
mdc11
 
PPTX
MVVM - Model View ViewModel
Dareen Alhiyari
 
PPTX
Introduction to WPF and MVVM
Sirar Salih
 
PPTX
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
PPT
Model View ViewModel
Doncho Minkov
 
PPTX
WPF For Beginners - Learn in 3 days
Udaya Kumar
 
PPTX
MvvmCross
ross.dargan
 
PPSX
Software Design Patterns
alkuzaee
 
PPTX
Presentation Model
Alex Miranda
 
PPTX
MVVM ( Model View ViewModel )
Ahmed Emad
 
PDF
Tool Development 10 - MVVM, Tool Chains
Nick Pruehs
 
PPTX
MVVM and Prism
Bilal Ahmed
 
PPTX
Mvvm in the real world tccc10
Bryan Anderson
 
PDF
Introduction To MVVM
Boulos Dib
 
Advanced MVVM in Windows 8
Gill Cleeren
 
Applied MVVM in Windows 8 apps: not your typical MVVM session!
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
MvvmCross Seminar
Xamarin
 
MvvmCross Introduction
Stuart Lodge
 
Mike Taulty MIX10 Silverlight Frameworks and Patterns
ukdpe
 
Introduction to MVVM Framework
Honeyson Joseph
 
MVVM Light Toolkit Works Great, Less Complicated
mdc11
 
MVVM - Model View ViewModel
Dareen Alhiyari
 
Introduction to WPF and MVVM
Sirar Salih
 
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
Model View ViewModel
Doncho Minkov
 
WPF For Beginners - Learn in 3 days
Udaya Kumar
 
MvvmCross
ross.dargan
 
Software Design Patterns
alkuzaee
 
Presentation Model
Alex Miranda
 
MVVM ( Model View ViewModel )
Ahmed Emad
 
Tool Development 10 - MVVM, Tool Chains
Nick Pruehs
 
MVVM and Prism
Bilal Ahmed
 
Mvvm in the real world tccc10
Bryan Anderson
 
Introduction To MVVM
Boulos Dib
 
Ad

More from bwullems (9)

PDF
GraphQL - A love story
bwullems
 
PDF
ElasticSearch - Search done right
bwullems
 
PPTX
Techorama - Evolvable Application Development with MongoDB
bwullems
 
PPTX
Git(hub) for windows developers
bwullems
 
PPTX
Javascript omg!
bwullems
 
PPTX
Tfs Monitor Windows Phone 7 App
bwullems
 
PPTX
Caliburn.micro
bwullems
 
PPTX
Convention over configuration in .Net 4.0
bwullems
 
PPTX
Visual Studio 2010 and .NET 4.0 Overview
bwullems
 
GraphQL - A love story
bwullems
 
ElasticSearch - Search done right
bwullems
 
Techorama - Evolvable Application Development with MongoDB
bwullems
 
Git(hub) for windows developers
bwullems
 
Javascript omg!
bwullems
 
Tfs Monitor Windows Phone 7 App
bwullems
 
Caliburn.micro
bwullems
 
Convention over configuration in .Net 4.0
bwullems
 
Visual Studio 2010 and .NET 4.0 Overview
bwullems
 

Recently uploaded (20)

PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
July Patch Tuesday
Ivanti
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Designing Production-Ready AI Agents
Kunal Rai
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 

Building an enterprise app in silverlight 4 and NHibernate

Editor's Notes

  • #2: Gill
  • #3: Gill
  • #4: Gill
  • #6: TraditionalN-tierleavestoomuchquestionsunansweredHow to handle the gap betweenvisualization and domain specification(how do youchangeyourrich domain model intosomethingthatcanbevisualized) Most business logicgotscatheredaround
  • #23: Ons query model tonen(is ook opgebouwd met nHibernate)DataServiceKey attribuutTravelPlannerQueryContextTravelPlannerQueryServiceDataServiceKey even aanpassen naar CityNameAantal voorbeeld urls tonen:/Cities/Cities(‘Paris’)/Cities(‘Paris’)/CityNameCities(‘Paris’)/name/$value/$metadataLinqPad tonen voor complexe gevallen