Switch on the LightSwitch
description
Transcript of Switch on the LightSwitch
![Page 1: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/1.jpg)
Switch on the LightSwitchGill CleerenMicrosoft Regional Director / Silverlight MVPOrdina Belgiumwww.snowball.be - @gillcleeren
![Page 2: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/2.jpg)
Glad to meet you!
• Gill Cleeren• Microsoft Regional Director• MVP Silverlight• .NET Architect @Ordina (www.ordina.be) • Speaker (TechDays, DevDays, NDC Norway, Spring Conference UK,
SQL Server Saturday Switzerland...)• Visug user group lead (www.visug.be)• Author (Silverlight 4 Data and services cookbook)• www.snowball.be - [email protected] - @gillcleeren
![Page 3: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/3.jpg)
Agenda
• Introduction: what and why LightSwitch?• Part 1: The basics
• Data• Screens• Queries• Small demo
• Part 2: Deeper dive• More on data• More on screens• More on queries• Writing code in LightSwitch• Security in LightSwitch• Deploying a LightSwitch application • Extending LightSwitch
![Page 4: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/4.jpg)
WHAT AND WHY LIGHTSWITCH?Introduction
![Page 5: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/5.jpg)
Not everyone is a developer...
This guy at least looks like one...
![Page 6: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/6.jpg)
Developers like working fast as well
This is not a Mac...
![Page 7: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/7.jpg)
What is LightSwitch?
An easy way to build business apps for desktop and cloud applications
![Page 8: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/8.jpg)
The LightSwitch Development Experience
Start
Describe your data
Create screens for common tasks
Refine
Author business logic
Customize screen layouts
Define custom queries
ExtendExplore ecosystem
components
Create custom Silverlight controls
Integrate with custom data sourcesAt this point, we already have
working app
(SL, MVVM, RIA Services)
![Page 9: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/9.jpg)
THE BASICSPart 1:
![Page 10: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/10.jpg)
Basic #1: Data
• Data is the base of our application• LS allows• Connecting to existing data sources• Newly created tables• Creating relations between tables• Even in one or more databases
• Based on data, LS will do• Field validation• Transactions processing• Concurrency checking
![Page 11: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/11.jpg)
Basic #1: Data
• LS can connect to• Existing SQL Server data base• SharePoint list• WCF RIA Service
• LS has an internal database as well, used for• Internal setting storage• Custom entities• LS allows changing internal fields, external can’t be
changed
![Page 12: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/12.jpg)
Basic #1: Data
• LS can create relations between data items• If items are in internal database• Doesn’t work between 2 external items• Works between 2 different types (internal and SQL Server for
example)
![Page 13: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/13.jpg)
Basic #2: Screens
• Screens allow us to display data • A LS app is made up of screens (which may seem logical)
• Creating a screen is done by:• Selecting the type of screen you want• Selecting the data you want • Have LS generate it for you
• These screens can be tweaked:• How they look• What features they offer• What commands they allow• ...
![Page 14: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/14.jpg)
Basic #2: Screens
• Types of screens that exist in LS:• New Data Screen• Search Data Screen• Details Screen• Editable Grid Screen• List and Details Screen• Your own!
![Page 15: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/15.jpg)
Basic #2: Screens
• Appearance of screens can be altered:• Using the Screen Designer (Visual Studio)• Customization Mode Screen (Run time, sends back the
changes to Visual Studio)
![Page 16: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/16.jpg)
Basic #3: Queries
• A query in LS returns data that matches some criteria• Return all products in selected category
• LS has internal query designer• A query becomes part of the model• Can be used to create (part of) screens from
![Page 17: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/17.jpg)
DEMOThe BookStore application
![Page 18: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/18.jpg)
DEEP DIVE INTO LIGHTSWITCHPart 2:
![Page 19: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/19.jpg)
MORE ON DATA
![Page 20: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/20.jpg)
Formatting data
• The Entity Designer is used to create and format data items• Cool stuff such as adding space in camel-cased words
• Business types are a layer on top of “normal” data types• Applies default validation• More cool stuff such as default domain on Email field
• Summary properties• Can be a “computed property”• Requires coding
• IDs are int by default• Fields can have a choice list as values• We can decide whether or not we want to show a data item• Custom validation is done by code
![Page 21: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/21.jpg)
Sorting and Filtering data
• For this, we need to change/create a query• Can be created specifically for a screen or on entity level to be
used throughout the application (global query)
![Page 22: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/22.jpg)
Types of data
• Data can be mixed between• Local (internal) data• External data
• Relations can be created between• Internal and internal• Internal and external
• LS can’t change an external model• Links to internal are visualized as dotted lines• External data is linked through Foreign key• This doens’t support transactions
![Page 23: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/23.jpg)
Coding the data
• LS generates objects and members that describe our data• Customer table Customer entity
![Page 24: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/24.jpg)
Coding the data
• Application• Top level object• Allows access to objects within the app• Can be used to retrieve active user
• Data Workspace• DW is top level for all data-access within app• Contains property for each data source• Default: ApplicationData• External: XXXData
![Page 25: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/25.jpg)
Coding the data
• Data Source• Object per data source in application• Members contain entity set properties and query methods• Entity Set returns collection of entities• Query methods gets results of a query• <Entity Name>_Single• <Entity Name>_SingleOrDefault
• EntityObject• Is generated for each entity in an entity collection• Contains members to delete or update an entity• Can be retrieved by calling query method that returns an
entity
![Page 26: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/26.jpg)
Types of external data
• LS can connect with• SQL Server Database• WCF RIA Services• SharePoint List• OData
• Not native, through workaround
• ...
![Page 27: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/27.jpg)
DEMOWorking with data
![Page 28: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/28.jpg)
MORE ON SCREENS
![Page 29: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/29.jpg)
Screen Designer
• LS has no drag and drop interface!• Screen Designer does the job• Can be used to• Add/remove items from a screen• Add buttons• Add items• Add custom controls• Change position
of items• ...
![Page 30: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/30.jpg)
Screen designer at runtime
• Screens can be edited while running in the debugger• Changes are sent back to Visual Studio• Gives preview including data
![Page 31: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/31.jpg)
Master-detail
• On one or more screens, we can easily create an editable master-detail functionality• Start with a search screen• Create a detail screen• Add the detail property as a summary on the search screen • Clickable to detail
• On the child, include a summary back to the masterThis is easy to work if the user has many screens open
![Page 32: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/32.jpg)
DEMOWorking with screens
![Page 33: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/33.jpg)
MORE ON QUERIES
![Page 34: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/34.jpg)
Query designer
• Visual design of queries• Filters• Sorting• Parameters
• Not everything is possible• We can code the
queries• Count(), Sum()...• Navigating properties
![Page 35: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/35.jpg)
DEMOWorking with queries
![Page 36: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/36.jpg)
WRITING CODE IN LIGHTSWITCH
![Page 37: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/37.jpg)
Code in LightSwith
• Code is required for• Business rules• Validation• ...
• LS has normal code editor (C# or VB, IntelliSense, Silverlight...)• Most code will be in default methods• Entities• Queries• Screens• <ScreenName>_CanRun() can be used to check
permissions on this screen from code
![Page 38: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/38.jpg)
Data events
• General methods that are run when data is created, deleted, or modified.
• Access control methods that are run when data is created, deleted, or modified.
• Query methods that are run when a data source is queried.• Query access control methods that are run prior to a query
executing.• Data source methods that are run when a data source is saved
to.• Property methods that are run when a property is modified.
![Page 39: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/39.jpg)
Screen events
• Button methods that are called when a button is clicked.• General methods that are called when data is loaded or saved, or
when a screen is closed.• Access control methods that are called to verify if a user has
permission to perform a task.• Collection methods that are called when a collection is modified.
![Page 40: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/40.jpg)
Code and screens
• We have access from code to change screens• Hide/show/enable elements• Set default values from code
![Page 41: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/41.jpg)
DEMOWriting code in LightSwitch
![Page 42: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/42.jpg)
SECURITY IN LIGHTSWITCH
![Page 43: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/43.jpg)
Authentication in LightSwitch
• 3 options in beta 2:• No authentication• Forms authentication• Windows authentication
• Specific user API built-in• Available after deployment to user specified during deploy
• SecurityAdministration
![Page 44: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/44.jpg)
Permissions in LightSwitch
• Securing an application starts with defining permissions• Developer must create these
• In code, we can then check the permission• Can be granted for debug mode
![Page 45: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/45.jpg)
DEMOSecurity in a LightSwitch application
![Page 46: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/46.jpg)
DEPLOYING A LIGHTSWITCH APPLICATION
![Page 47: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/47.jpg)
Deployment options
• Desktop client• 2-tier deployment creates an application that runs on the
end-user’s Windows desktop; the database and server components run on a networked computer.
• Desktop client• 3-tier deployment creates an application that runs on the
end-user’s Windows desktop; the database and server components run on a server that is running Internet Information Services (IIS) or on Windows Azure.
• Browser client• 3-tier deployment creates an application that runs in the end-
user’s web browser; the database and server components run on a server that is running IIS or on Windows Azure.
![Page 48: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/48.jpg)
Desktop, 2 tier deployment
Silverlight 4 Out-Of-Browser App.NET Framework 4.0
All LightSwitch Components (DLLs)
![Page 49: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/49.jpg)
Desktop, 3 tier deployment
Clients can be on the Internet or same network
Silverlight 4Out-Of-Browser App
(Office Integration possible)
Internet Information Server (IIS)NET Framework 4.0
LightSwitch Middle-tier components
![Page 50: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/50.jpg)
Browser, 3 tier deployment
Clients can be on the Internet or same network
Silverlight 4Browser App
Internet Information Server (IIS)NET Framework 4.0
LightSwitch Middle-tier components
![Page 51: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/51.jpg)
Publishing to Windows Azure
![Page 52: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/52.jpg)
DEMODeploying a LightSwitch application
![Page 53: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/53.jpg)
EXTENDING LIGHTSWITCH
![Page 54: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/54.jpg)
Where to extend?
• LightSwitch has 6 extensibility points
![Page 55: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/55.jpg)
Extending LightSwitch
• Possible to combine multiple extensions:• An extension provides a Money Market solution by using a
Shell that has specific trading navigation• A theme that is specific to the trading company• A number of screen templates and controls that provide
visualizations for trading data• A custom data source could be the extension that aggregates
the data to the application
![Page 56: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/56.jpg)
EXTENSION HOOKS
![Page 57: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/57.jpg)
Controls
![Page 58: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/58.jpg)
Business types
• A Business type provides a way to visualize, format, validate and store information/data• Basically, this is just a visual formatting on data
![Page 59: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/59.jpg)
Screen templates
![Page 60: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/60.jpg)
Shell
![Page 61: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/61.jpg)
Theme
![Page 62: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/62.jpg)
Custom data source
![Page 63: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/63.jpg)
DEMOUsing extensions in LightSwitch
![Page 64: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/64.jpg)
Summary
• LightSwitch is a nice tool to build LOB app with• Easy• For developers and “non-developers”• Fast• Choice of deployment options• Extensible
![Page 65: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/65.jpg)
Q&A
![Page 66: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/66.jpg)
THANK YOU
![Page 67: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/67.jpg)
Stay up to date with MSDN Belux
• Register for our newsletters and stay up to date:http://www.msdn-newsletters.be• Technical updates• Event announcements and registration• Top downloads
• Follow our bloghttp://blogs.msdn.com/belux
• Join us on Facebookhttp://www.facebook.com/msdnbehttp://www.facebook.com/msdnbelux
• LinkedIn: http://linkd.in/msdnbelux/ • Twitter: @msdnbelux
Download MSDN/TechNet Desktop Gadget
http://bit.ly/msdntngadget
![Page 68: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/68.jpg)
TechDays 2011 On-Demand
• Watch this session on-demand via Channel9http://channel9.msdn.com/belux
• Download to your favorite MP3 or video player• Get access to slides and recommended resources by the speakers
![Page 69: Switch on the LightSwitch](https://reader036.fdocuments.net/reader036/viewer/2022081507/56815d73550346895dcb7dcf/html5/thumbnails/69.jpg)
Switch on the LightSwitchGill CleerenMicrosoft Regional Director / Silverlight MVPOrdina Belgiumwww.snowball.be - @gillcleeren