Nuno Filipe Godinho

All about WebDevelopment (ASP.NET & Silverlight)

Sponsors

September 2009 - Posts

Silverlight 4 Previewed in Amsterdam

   Silverlight 3 just got out and already we are hearing about the new version, and this is one of the huge advantages that Silverlight has (IMHO of course), because we know that they are always trying to get more into there without sacrificing the size and the cross-browser and platform of the technology.

   One of the first sneaks about the new Silverlight 4 was in Amsterdam as you can read more here, in this The Inquirer article.

“(…)In an early preview of Silverlight 4 media-specific features, the Vole showed off what its next generation of movie experiences could do even when saddled with its offline PlayReady DRM. (…)

“(…) A spokes Vole said that Silverlight 4 will enable movie studios to offer network-delivered updates, special offers and live events, and flog more than just one or two movies to punters (…)

I say, hum interesting, I would love to know more about the new features so I’ll keep blogging when that happens.

SaaS Architecture

   When building Software as a Service (SaaS) solutions one of the things that is very important to consider is the Multi-Tenancy of the Database, and the different approaches that available in order to achieve the best option.

   The option is always the same in every part of any solution, and this is from a Fixed Solution to a Fully Configurable Solution, and a SaaS solutions normally starts somewhere in the middle, that is when different customers can have different functionalities and even different UX. But a very important thing to acknowledge is the fact that in order to maintain this kind of differences we need a data model that needs to be Multi-Tenant, and so the next choice to make is the Multi-Tenancy approach that will be used, and it can be:

  • Separate Databases for each Customer
    • Isolation, The most Isolation we can have, and the one we can be sure that no customer can access other customer’s data
    • Customization, Each customer can have different data model without affecting other customers
    • Performance, The fact that the data is isolated allows that the several customers have performances accessing that are dependent only on their amount of data, and not other customers data.
    • Manageability, Whenever a customer has a problem with the data on the solution, or needs a migration, or backups are easier to achieve since they are isolated.
  • Same Database, Separate Schemas for each Customer
    • Isolation, This is in the middle way since we have from one side the data isolated since we have different schemas for each customer, but all resides on the same database, simplifying the number of databases that reside on our server.
    • Customization, Each  customer can have different data models without affecting others
    • Performance, The fact that the data resides on the same database as other customers, the amount of data from other customers can affect the performance of accessing the data, but of course this can be simplified by using Partitioning on the database.
    • Manageability, Whenever a customer has a problem with the data on the solution or even a migration it’s still not so hard since we have different schemas for each customer, but for separate backups this is not that easy.
  • Same Database, Same Schema for each Customer
    • Isolation, This is the less isolated solution for data since everything reside exactly on the same tables, and database, and then this will simplify the number of Databases and Database objects on the server.
    • Customization, This makes that every customer have the same schema, and so customization is only possible using approaches like:
      • Having several Custom columns on the tables, like, Custom1, Custom2, and so on.
      • Having a table for customizable columns, like ColumnName, ColumnType, ColumnValue.
    • Performance, The fact that the data is nor isolated makes that the amount of data from other customers affect the performance of accessing data, but of course this can also be achieved using Partitioning on the database based on the for instance in the TenantID.
    • Manageability, This becomes harder since everyone's data is on the same tables and so the separation of the backups, as well as the manageability of the customers data becomes harder, but the possibility to run checks on customers data became easier since we always know at front the schema used for each customer.

   A very interesting document regarding this subject is this one that is part of the MSDN site, and that is called “Multi-Tenant Data Architectures”. Another interesting reading about this subject is this article from Scott Mitchell in the 4GuysFromRolla community site about “Querying a Multi-Tenant Data Architecture”.

   In order to know more about SaaS architecture and solutions I’ll suggest the following articles:

   Hopes this can help you get started or even with your choices in terms of Multi-tenancy of Data.

New Features in Visual Studio 2010

Visual Studio 2010 is approaching rapidly from the launch and with it a new set of features will also appear.

One that I think is very important is the Architectural Tools that come with this new version, and elements like:

  • Dependency Graph
    • Filters using Direct Graph Markup Language (DGML) on top of the generated graph.
    • Views as:
      • Dependency Matrix
      • Forced Direct Layout
      • Top to Bottom Layout

 

  • Sequence Diagrams
    • Available on the Code Editor

 

  • Unified Modeling Language (UML)
    • Usage of UML to define the project

 

  • Use Cases (UC)
    • Creation of Use Cases
    • Integration with TFS, since we can select an element in the use case and build, link or View the associated Work Items.

 

  • Layer Designer and Layer Validation
    • Possibility do build the Architecture of the solution and associate some validation elements that will always be enforced during the development process.

   To know more about this subject read this S.Somasegar post.

Another very important features are the Debugging and Profiling.

  • Debugging
    • Built in Debugger for MPI programs. Now with the new VS2010 we can select a cluster head node, how many cores you want, and hit F5 to debug your MPI program.
    • SOA Debugging
      • Up until now, debugging Cluster SOA was limited to basic WCF/.Net style debugging with no cluster integration.
      • In Visual Studio 2010, an add-in for Cluster SOA enables the SOA Settings tab, allowing you to choose a head node, debug nodes and services, deploy runtime libraries and clean up automatically.

 

  • Profiling
    • VS Profiler can offer insight into performance issues
    • Shows a comparison report across multiple runs or builds so you can easily see the effect of your changes.

 

   To know more about this subject read this S. Somasegar post.

Prism and .NET RIA Services

   Prism is a real interesting Guidance and was built for Silverlight 2.0, and some of the feedback I’ve received is if it works well with the new version 3.0, and so I remembered blogging about this.

   The most usual questions are:

1. Does this work well with Silverlight 3 ?

    • Yes it works fine with this new version of Silverlight.

2. Does this work well with .NET RIA Services ?

    • Yes. They don’t only work well together, they actually complement each other, since one of the elements in the product backlog of the Prism Team was the access to server data, and since they didn’t had time to do this, .NET RIA Services can do this for them.

In order to know more about the subject read this David Hill’s post.

About how to have quick starts about Prism read this other David Hill’s post.

ADO.NET Data Services v1.5 CTP2 usage in Silverlight

   After all the information’s regarding the ADO.NET Data Services v1.5 CTP2, now the Product Team launched a tutorial in how to use this version with Silverlight from another domain and also out-of-browser. And so I think this is important for everybody that is working in Silverlight.

In order to know more about the subject read this post from the Product Team.

Complex Event Processing (CEP) from Microsoft

Recently in a GASP (Grupo de Arquitectura de Software Português) we had a presentation regarding the need and the usage of CEP in solutions and the implementation presented was NESPER – Esper Complex Event Processing for .NET that is an Open-Source software available under GNU General Public License (GPL) v2. From what I saw there it’s very interesting and also not that difficult to use, but I always thought that it was strange that Microsoft was doing nothing regarding this subject that is so important in Event-Driven Architectures (EDA) or even called Advanced SOA.

Our wait is reaching an end, because Microsoft is already working on this and even already has a CTP version that can be downloaded here and that is called Microsoft® SQL Server® StreamInsight CTP2.

But what is Microsoft® SQL Server® StreamInsight CTP2?

“Microsoft® SQL Server® StreamInsight is a platform for the continuous and incremental processing of unending sequences of events (event streams) from multiple sources with near-zero latency. These requirements, shared by vertical markets such as manufacturing, oil and gas, utilities, financial services, health care, web analytics, and IT and data center monitoring, make traditional store and query techniques impractical for timely and relevant processing of data.
StreamInsight allows software developers to create innovative solutions in the domain of Complex Event Processing that satisfy these needs. It allows to monitor, mine, and develop insights from continuous unbounded data streams and correlate constantly changing events with rich payloads in near real time. Industry specific solution developers (ISVs) and developers of custom applications have the opportunity to innovate on and utilize proven, flexible, and familiar Microsoft technology and rely on existing development skills when using the StreamInsight platform.
Some of the key feature areas are:

  • Derive meaningful and relevant information from data/events streams through complex patterns. These patterns can be defined using a declarative query paradigm based on well-defined streaming semantics with LINQ as query language.
  • For the development of applications, adapters, and analytics, the user can rely on well-established and powerful development frameworks and tools such as .NET, LINQ, and Microsoft Visual Studio.
  • The platform integrates with various data sources and sinks through input and output adapters. The framework to build domain-specific adapters utilizes a .NET API to make adoption of the platform easy. Independence between adapters and queries facilitates seamless integration of real-time and historical analysis.
  • The platform architecture supports a variety of deployment options, from scenarios with a low-footprint embedded option to high-end server deployments.
  • A rich set of manageability features such as a management interface, a diagnostic interface and a debugging tool are provided as part of the platform. “ (from the Microsoft site)

To know more about the licensing terms of this new product, check here.

From what I’ve checked there are some interesting comments regarding this subject like this Richard Seroter’s post in the “Low Latency Data and Event Processing with Microsoft SQL Server “ part of that post.

Another comment about this is from Charles Young in this post.

I’ll investigate a little bit more and I’ll give more information’s afterwards.

New Features in CTP2 ADO.NET Data Services v1.5 Explained

After yesterdays post about the availability of the CTP2 of ADO.NET Data Services v1.5 here are some more details regarding the Projections, Feed Customization and Data Binding.

As told before Projections, the possibility of getting only the columns chosen instead of retrieving all the columns. With this we have now a new set of expressions to provide this ability on the URI, and in order to achieve we have now two new keywords available, that are:

 

 

  • But in order for this to work we need to add the following 2 properties to the service:
    • First, make projections available using the URI.
        1: config.DataServiceBehavior.AcceptProjectionRequests = true;
    • Secondly, make the protocol version to V2
        1: config.DataServiceBehavior.MaxProtocolVersion = System.Data.Services.Common.DataServiceProtocolVersion.V2;

 

  • For more information’s regarding this subject read this post from the Product Team.

 

Feed Customizations are the possibility to customize the way the feed is created instead of using only the default AtomPub version.

  • In order to achieve this customization we must use the EntityPropertyMappingAttribute that will define the relationship between the Property and the name that will be used in the feed.

                    In the following sample we are defining that when building the feed, instead of using the complete type definition

        1: <author>
      
        2:    <name>Nuno Godinho</name>
      
        3:    <email>someone@company.com</email>
      
        4: </author>

                   we will have the Author element with the value that is on the Name Property of the Author class (considering that Author is a type that contains several properties and one of them is Name):

 

Data Binding is now simplified, because using the DataServiceCollection class we can bind it directly to the Data Service.

  • For more information’s regarding this subject read this post from the Product Team.
New version CTP of ADO.NET Data Services v1.5 is now available

ADO.NET Data Services (aka Astoria) has now the CTP2 release for version 1.5 available that will have the following new features:

  • Projections, the possibility of getting only the columns chosen instead of retrieving all the columns. With this we have now a new set of expressions to provide this ability on the URI.
  • DataBinding, Simplification of the DataBinding for Silverlight and WPF, because using the DataServiceCollection class we can bind it directly to the Data Service.
  • Row Count, Ability to determine the number of elements in a set of entities without having to retrieve them all.
  • Feed Customization, Possibility to customize the way the feed is created instead of using only the default AtomPub version.
  • Server Driven Paging, Provides the ability to define the number of elements retrieved by a request, and also the server will provide a link to the Next and Previous results page.
  • Enhanced BLOB support, enable data services to stream arbitrarily large BLOBs, store binary content separate from its metadata, easily defer the loading of BLOB content when its metadata is requested, etc.
  • Request Pipeline, Possibility to handle the several events that occur during the Request because in the version we have access to a complete set of Request Level Events.
  • New Interface for Custom Providers Writer, New model to develop Custom Providers for ADO.NET Data Services, like here.

You can download it here, and to know more about the subject, read this post about this by the Product Team.

TemplateBinding inside ControlTemplate.Triggers

One of the limitations of TemplateBinding Markup in WPF is the fact that we cannot use it inside the ControlTemplate.Triggers because it really doesn’t work, since as Mike Hillberg said here, “TemplateBinding is a lightweight, but less functional, version of a Binding with a RelativeSource of TemplatedParent.  One of the things that a TemplateBinding can't do is work within the ControlTemplate.Triggers; TemplateBinding only works within the template content” .

So we have this:

       MyControl.cs

  1: 	public class MyControl : Control
  2: 	{
  3: 
  4: 		public Boolean Selected
  5: 		{
  6: 			get { return (Boolean)GetValue(SelectedProperty); }
  7: 			set { SetValue(SelectedProperty, value); }
  8: 		}
  9: 
 10: 		// Using a DependencyProperty as the backing store for Selected.  This enables animation, styling, binding, etc...
 11: 		public static readonly DependencyProperty SelectedProperty =
 12: 			DependencyProperty.Register("Selected", typeof(Boolean), typeof(MyControl), new UIPropertyMetadata(false));
 13: 
 14: 
 15: 
 16: 		public Brush SelectedColor
 17: 		{
 18: 			get { return (Brush)GetValue(SelectedColorProperty); }
 19: 			set { SetValue(SelectedColorProperty, value); }
 20: 		}
 21: 
 22: 		// Using a DependencyProperty as the backing store for SelectedColor.  This enables animation, styling, binding, etc...
 23: 		public static readonly DependencyProperty SelectedColorProperty =
 24: 			DependencyProperty.Register("SelectedColor", typeof(Brush), typeof(MyControl), new UIPropertyMetadata(Brushes.Red));
 25: 
 26: 
 27: 		public MyControl()
 28: 		{			
 29: 		}
 30: 
 31: 		protected override void OnInitialized(EventArgs e)
 32: 		{
 33: 			base.OnInitialized(e);
 34: 
 35: 			this.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(MyControl_MouseLeftButtonDown);
 36: 		}
 37: 
 38: 		void MyControl_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 39: 		{
 40: 			MessageBox.Show(this.SelectedColor.ToString());
 41: 			this.Selected = !this.Selected;
 42: 		}
 43: 	}
 44: 

      Window1.xaml

  1: <Window x:Class="WpfApplication13.Window1"
  2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4: 	xmlns:local="clr-namespace:WpfApplication13"
  5:     Title="Window1" Height="300" Width="300">
  6:     <Grid>
  7: 		<local:MyControl x:Name="ctrl1">
  8: 			<local:MyControl.Template>
  9: 				<ControlTemplate TargetType="{x:Type local:MyControl}">
 10: 					<Grid Background="Green" x:Name="source"/>
 11: 					<ControlTemplate.Triggers>
 12: 						<Trigger Property="Selected" Value="true">
 13: 							<Setter TargetName="source" Property="Background" Value="{TemplateBinding SelectedColor}"/>
 14: 						</Trigger>
 15: 						<Trigger Property="Selected" Value="false">
 16: 							<Setter TargetName="source" Property="Background" Value="Green"/>
 17: 						</Trigger>
 18: 					</ControlTemplate.Triggers>
 19: 				</ControlTemplate>
 20: 			</local:MyControl.Template>
 21: 		</local:MyControl>
 22: 	</Grid>
 23: </Window>
 24: 

When we compile we get the following error, "Cannot convert the value in attribute 'Value' to object of type ''.  Error at object 'System.Windows.Setter' in markup file 'WpfApplication13;component/window1.xaml' Line 13 Position 58."

So how can we solve this problem?

   Since the problem here is that TemplateBinding is not supported inside the ControlTemplate.Triggers, we have to find another way to make the binding, and so we just change the line 13 to

  1: 							<Setter TargetName="source" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedColor}"/>

      And if we look at the TemplateBinding Markup page in MSDN, the usage of TemplateBinding is similar to the Binding Markup using TemplatedPart as the RelativeSource, like {Binding RelativeSource={RelativeSource TemplatedParent}, Path=DependencyPropertyToBind}

Hope this helps.

More Posts