QUESTION: Describe the data handling capabilities of Silverlight especially in handling complex data sets that involve hundreds of rows of data from dozens of tables with thousands of columns involved.
This question implies two concerns: (1) How do I query relational and other data stores that are complex and varied? (2) With lots of data how do I deal with performance?
How do I query relational and other data stores that are complex and varied?
Complex data sets can be represented in a variety of ways with Microsoft technology. Microsoft offers several solutions that address data stores and querying relational data. Below is a list of Microsoft technologies that address being able to interact with data over the web with Silverlight.
The basic flow in Visual Studio is:
- Create a project
- Create an entity model using ADO.NET Entity Framework or LINQ-to-SQL or “other.”
- Create a data service
- Enable access to service
- Program Silverlight to interact with .svc file to retrieve data and perform CRUD operations.
One chief goal is to expose data using a uniform interface to be consumed by Web clients across a corporate intranet or the Internet in an efficient manner. Silverlight is capable of interacting with the following list of technologies:
ADO.NET Data Services
The ADO.NET Data Services framework consists of a combination of patterns and libraries that enable the creation and consumption of data services for the web. Developers wish to manipulate the results in terms of objects, and handle aspects such as association traversal. The client libraries abstract away the details of HTTP requests and responses and also ensure a more uniform experience across each of the client stacks.
In general, the goal of the ADO.NET Data Services Framework is to create a simple framework based on Representational State Transfer (REST) for exposing and consuming data-centric services.
ADO.NET Data Services works closely with the ADO.NET Entity Framework to simplify the process of connecting to and exposing a data model over data stored in SQL Server® or other third-party databases (Oracle, DB2, MySQL, to name merely a few).
The goal of the ADO.Net Data Services framework is to facilitate the creation of flexible data services that are naturally integrated with the web, using URIs to point to pieces of data and simple, well-known formats to represent that data, such as JSON and plain XML.
This results in the data service being surfaced to the web as a REST-style resource collection that is addressable with URIs and that agents can interact with using the usual HTTP verbs such as GET, POST or DELETE. Each of the four CRUD operations (Create, Retrieve, Update, Delete) are mapped to a different HTTP verb with Retrieve mapped to GET, Create mapped to POST, Update mapped to PUT, and Delete mapped to DELETE. Queries are executed through ADO.NET Data Services mapped through HTTP Get requests.
This mapping to HTTP verbs is abstracted from the developer through the use of method calls on simple DataService objects.
Each ADO.NET Data Service is described in Entity Data Model (EDM) terms using the Conceptual Schema Definition Language (CSDL). The EDM uses two primary concepts, entities and associations (or relationships). Entities are instances of Entity Types (such as Customer or Employee) which are structured records with a key.
Example of setting security rights
By default, any new ADO.NET Data Service is fully locked down. You can control authorization policy and perform per-request validations against your data service. You can change rights as follows.
void InitializeService(IDataServiceConfiguration config)
Integration With ASP.NET and WCF
ADO.NET Data Services leverages much of the existing ASP.NET and WCF authentication infrastructure to allow for an integrated authentication experience across applications and through the service.
ADO.NET Entity Framework
The ADO.NET Data Services Framework began as a way to help developers looking to expose and consume data via services from their RIA applications, separating presentation and data to enable a more interactive and responsive application. Rather than coding against rows and columns, a higher-level conceptual model is defined.
The goal is to understand data in the shapes that make sense for the application and those shapes are expressed using a rich vocabulary that covers concepts such as inheritance, complex types, and explicit relationships.
Microsoft® Entity Data Model (EDM), based on Dr. Peter Chen’s Entity Relationship (ER) model, is really the driving force behind the ADO.NET Entity Framework.
The EDM builds on the ER model to raise the abstraction level for models an order higher than logical models while still preserving the concepts of entities and relationships.
Reporting, Visualization, Data Input
EDM can be used to define a model not only for custom applications built on the ADO.NET Entity Framework but also as the input to reporting and visualization applications, intranet portal applications, or workflow applications.
Microsoft LINQ defines a set of proprietary query operators that can be used to query, project and filter data in arrays, enumerable classes, XML (XLINQ), relational database, and third party data sources.
LINQ to SQL is an O/RM (object relational mapping) implementation that ships in the .NET Framework “Orcas” release, and which allows you to model a relational database using .NET classes.
You can then query the database using LINQ, as well as update/insert/delete data from it.
LINQ to SQL fully supports transactions, views, and stored procedures.
It also provides an easy way to integrate data validation and business logic rules into your data model. work with a strongly types collection of objects as a return result. We can make changes to these objects then save changes back to the database.
Visual Studio “Orcas” ships with a LINQ to SQL designer that provides an easy way to model and visualize a database as a LINQ to SQL object model.
WCF Exposing REST or SOAP data– based data model (could leverage complex stored procedures)
WCF is the Microsoft framework for building applications that communicate over a network, regardless of the style or protocol.
When you create an ADO.NET Data Service, you are utilizing WCF by definition.
The concept behind WCF was to create a framework that was extensible and pluggable so that developers could learn one programming and configuration model and be able to apply those skills to many different kinds of distributed systems.
While it is true that much of WCF is geared toward RPC (using SOAP), it actually has had the ability to expose and consume REST services since it was first released as part of the .NET Framework 3.0.
What it lacked was a programming model needed to make using REST with WCF easy.
Internally developed custom models
Large enterprise customers may already have custom UI generation tools in-house already.
Chattiness of application
# of Web Objects * Chatty HTTP Protocol * Latency = Slow Application
Typically organizations try to accomplish web acceleration by caching static objects in a reverse proxy cache, offloading SSL from busy web servers to a network device, and offloading compression from the web servers to a network device.
Size of data sets
Controlled by paging and intelligent query use.
Using Page size intelligently
Level of caching affecting network bandwidth
See discussion of VELOCITY.
Large Data Capabilities
Leverage Paging and caching.
Extending the Data Layer
Support security, caching, validation
Silverlight 3.0 capabilities
Need to expand this.
QUESTION: How are these handled in caching within the VM? Can data be cached for multiple logical sessions within the same VM session or application?
Depends on the nature of data relationships among various logical sessions.
Will the data be the same among all the instances of a Silverlight application?
Is there significant communication between multiple modules running in the same VM or other VMs?
Microsoft announced the first Community Technology Preview of Velocity, a distributed caching technology designed to provide an intermediate data cache independent of a back-end database for these needs. See discussion below.
Distributed Caching using Velocity
I’m guessing that large enterprises will wish to scale through clustering of web servers that are VM based.
A key goal of scaling is to avoid a server going down and a bunch of clients losing session state.
AJAX and MVC, more web services are becoming dependant on this state data.
There is a need for a middleware layer that will tie together the servers that allows data to be placed in the distributed cache, which is globally scalable. Distributed caches are designed to hold relatively fast changing data with a short lifetime and with more updates that you would see in a traditional database. Distributed caches work better than typical relational databases for storing intermediate state information.
More can be read below in 2 questions.
Key features of Velocity
Global accessibility – if you put an object in the cache, the middleware layer will eliminate server affinity
Scalable performance – the performance needs to grow with the number of participating servers so that it does not become a bottleneck.
High availability – it needs to remain available even after the loss of an individual server.
QUESTION: Is there a way to cache dictionary data that is used in drop downs and radio buttons in the VM and have it reused between sessions or application instances?
Seems like Velocity
QUESTION: Is there a refreshing mechanism for dictionary data that is cached? Describe more.
Microsoft project code named “Velocity” provides a highly scalable in-memory application cache for all kinds of data.
By using cache, you can significantly improve application performance by avoiding unnecessary calls to the data source. Data for drop downs and ratio buttons can be easily cached to avoid too much chattiness to the database.
Distributed cache enables your application to match increasing demand with increasing throughput by using a cache cluster that automatically manages the complexities of load balancing.
“Velocity” fuses memory across multiple computers to give a single unified cache view to applications.
Applications can store any serializable CLR object without worrying about where the object gets stored.
Scalability can be achieved by simply adding more computers on demand.
“Velocity” also allows for copies of data to be stored across the cluster, thus protecting data against failures.
Data platform developer center
Microsoft Data Platform Development Technical Article
Blog for Velocity
Documentation (CTP 3)
Microsoft Project Code Named “Velocity” Community Technology Preview 3 (CTP3)
Microsoft Project Code Name “Velocity” – Samples
QUESTION: How are repeating rows within repeating rows handled in the UIs? Does filtering of deeper records happen automatically?
Confusing what this means. Will need to clarify.
QUESTION: Can software frameworks be used to wrapper and extend the basic controls to provide caching and UI filtering in its level instead of having to repeat it in each and every application that is written?
There are many options to exteding the basic controls to provide caching and UI filtering.
One approach is to make use of the Silverlight Toolkit.
The Silverlight Toolkit is a collection of Silverlight controls, components and utilities made available outside the normal Silverlight release cycle.
It adds new functionality quickly for designers and developers, and provides the community an efficient way to help shape product development by contributing ideas and bug reports.
It includes full source code, unit tests, samples and documentation for 16 new controls covering charting, styling, layout, and user input.
QUESTION: Can validation code or control of it be factored out of the UI code so that it can be applied from models? And to keep UI code simpler and more painted rather than coded.
Yes. Code Behind implemented as “partial” classes support this
Partial classes can spread the definition of a class over multiple files. Partial classes attempt to solve the problem of separation of designer code and implementation code.
Validation can take place in code behind in a partial class.
void Register_Click(object sender, RoutedEventArgs e)
// Clear the status text
registerStatus.Text = “”;
if (newPassword.Text.Length == 0)
// No password entered
registerStatus.Text = “Enter a password.”;
Generic and re-usable validation
This is typical code that can be put hooked up in a generic fashion. On CodePlex, there is a project called, “Silverlight Validation Framework.” http://Silverlightvalidate.codeplex.com/. Examples can be found here, http://www.vinsolutions.com/validatordemotestpage.aspx.
Code samples might include:
new ValidationItem(new AlnumValidator(false), txtUsername, TextBox.TextProperty),
new ValidationItem(new NotEmptyValidator(), txtPassword, TextBox.TextProperty)
new ValidationItem(new NotEmptyValidator(), txtOpenId, TextBox.TextProperty),
new ValidationItem(new EmailAddressValidator(), txtOpenId, TextBox.TextProperty)
Silverlight has built-in validation for UI controls that takes data annotated model information and uses it
Event code that provides validation can also be implemented with code-behind and partial classes.
QUESTION: Can UI code be eliminated entirely with software frameworks that run using models? And allow UIs to be repainted without need for programmers (even HTML programmers)?
UI code is based on XAML and Code Behind. Somehow, someway this code needs to be created.
It can be created using code generation approaches. To what extent this code auto-generated versus hand-coded is the tooling. It also depends on how the Silverlight controls are extended. It depends on many factors.
Silverlight’s abstraction is XAML – What is XAML?
XAML simplifies creating a UI for the .NET Framework programming model.
You can create visible UI elements in the declarative XAML markup, and then separate the UI definition from the run-time logic by using code-behind files, joined to the markup through partial class definitions.
Partial Class Definitions
Allow designers and coders to extend the programming model for developing user interfaces. You could use an automated code gen tool to generate boilerplate XAML code that are sourced from table definitions, or other internally developed object models.
The ability to mix code with markup in XAML is important because XML by itself is declarative, and does not really suggest a model for flow control.
An XML based declarative language is very intuitive for creating interfaces ranging from prototype to production, especially for people with a background in web design and technologies. XAML can be generated and compiled into dlls, and loaded at runtime.
Unlike most other markup languages, XAML directly represents the instantiation of managed objects.
This general design principle enables simplified code and debugging access for objects that are created in XAML.
Yes. The Silverlight Toolkit offers some capabilities here.
Other approaches to streamline code development – What is the Silverlight Toolkit?
The Silverlight Toolkit is a collection of Silverlight controls, components and utilities made available outside the normal Silverlight release cycle. It adds new functionality quickly for designers and developers, and provides the community an efficient way to help shape product development by contributing ideas and bug reports. It includes full source code, unit tests, samples and documentation for 16 new controls covering charting, styling, layout, and user input. This source code could be leveraged to generate graphical interfaces.
CodeProject contains examples
This a reference implementation of creating Uis in an automated fashion. This project is called PropertyGrid and is an implementation for Silverlight 2.0.
A propertygrid is a useful control that allows for dynamic user interface creation. You simply give the control the object you wish to edit and the UI is dynamically created for you.
The implementation uses the Expander control contained in the Silverlight Toolkit.
Caveat – Defining “usability”
Computer generated user interfaces, based on models, are often lacking in “usability.” The value of such approaches are only as good as the code gen and the underlying models.
QUESTION: Are UIs abstracted from all client side code so that different UIs can be added easily (I.e. To scale to other devices line smart phones etc)?
Both the XAML code and the code-behind can be automatically generated and compiled with minimum human interaction. The UI effectiveness is only as good as the code generator and the modeling software and how well you have represented classes and interfaces, together with association, generalization, and implementation relationships.
In the case of Silverlight on SmartPhones there are plans for such support but non directly available today. SmartPhones on Windows Mobile allow a WinForm approach to programming. WinForms have been around for a long time and code generating those interfaces is commonplace. There are also mobile versions of controls available from Windows Mobile ISVs that provide SmartPhone appropriate functionality.
Current Silverlight programming models are likely to be extremely compatible with future SmartPhone programming models. There will be XAML. There will be code-behind. Code generating XAML and code-behind
There are already examples on the web that illustrate these concepts. For example, you can automate working with the dependency property framework. Whilst the framework itself is beautiful in concept, the dependency properties themselves take a lot of detail work. http://www.codeproject.com/KB/WPF/DependencyPropertyCodeGen.aspx is a reference application for this.
There is also a great article called, “Generating Artifacts By Using Text Templates” (http://msdn.microsoft.com/en-us/library/bb126445.aspx). A text template transformation toolkit that supports the processing of text templates. A text template is a file that contains a mixture of text blocks and control logic. When you transform a text template, the control logic combines the text blocks with the data in a model to produce an output file. You can use text templates to create text artifacts such as code files and HTML reports. For example, a model of the flow of control between the individual pages in a user interface, such as a wizard, can be passed as input to a text template. The text template can generate code and configuration files that implement that flow of control.
Allows you to:
After creating models, you can iterate over their in-memory-representation (instead of their raw XML representation) to generate arbitrary text
You can generate custom code by using either Visual C# or Visual Basic to navigate through a model
You can generate custom reports in XML or HTML
QUESTION: Is Silverlight being ported to Smartphones like iPhone?
On mobile devices, Silverlight provides a homogenous platform for developers to target a large number of devices as well as deliver rich interactive applications with vector graphics UI and mobile-optimized media. Further, Silverlight for mobile enables developers to reuse their existing desktop code, content and skills and leverages the flexible .NET programming model.
http://Silverlight.net/learn/mobile.aspx the iPhone question always comes up. Please help them understand that platforms 1st have to allow frameworks before we can even consider it. iPhone browser does not support a plugin model right now.
QUESTION: Can code be delivered dynamically to the client side in packages which may be compiled at different times and by different people?
The .NET Framework exposes classes that allow you to programmatically access the C# language compiler.
This might be useful if you want to write your own code-compiling utilities
// Create a new CodeCompileUnit to contain
// the program graph.
CodeCompileUnit compileUnit = new
// Declare a new namespace called Samples.
CodeNamespace samples = new
// Add the new namespace to the compile unit.
Dynamic Assembly Loading
void OnLoadDynamicEditor(object sender, EventArgs args)
WebClient client = new WebClient();
client.OpenReadCompleted += new OpenReadCompletedEventHandler(OnAssemblyOpened);
void OnAssemblyOpened(object sender, OpenReadCompletedEventArgs e)
AssemblyPart assemblyPart = new AssemblyPart();
Assembly assembly = assemblyPart.Load(e.Result);
editor = assembly.CreateInstance(“Implementation.Editor”) as IEditUI;
if (editor != null)
editor.TextChanged += OnEditorTextChanged;
QUESTION: Describe the abstraction layers supported by Silverlight from data caching, to data display, to data field validation, to data lookups, to page end validations to application end validations.
QUESTION: How are composite controls used and can be extended to handle repeating data (sub tables) easily? And to handle repeating within repeating data too?
XAML – Natively supports composite controls
Notice the list box has a stack panel has both an image and text. There is no limit to nesting other than usability or performance.
<ListBoxItem Background=“LightCoral” Foreground=“Red”
<Image Source=“coffie.jpg” Height=“30”></Image>