Archive

Archive for March, 2011

Business Data Validation

March 30, 2011 1 comment

Using CodeFluent Entities you can set business validation rules on properties in your model, which the Business Object Model (BOM) Producer will into actual C# code. Out-of-box validation rules include:

  • String validation (e.g. non null, non empty, etc.),
  • Comparison validation (e.g. value x compared to value y with a specific operator) ,
  • Regular Expression validation (e.g. check regexp matches),
  • Object validation (e.g. object is non null),
  • Url validation (e.g. is a valid url, on a specific port or scheme if desired),
  • Email validation (e.g. is a valid email, from a valid domain if desired),
  • Luhn code validation (e.g. is a valid Luhn Code such as a social security number or credit card number),
  • or your own custom validation rule.

For instance, let’s add an email validation rule on a property:

image

The BOM producer will automatically generate a validation method including the following code:

protected virtual void ValidateMember(CultureInfo culture, string memberName, IList<CodeFluentValidationException> results)
{
     if (((memberName == "Email") || (memberName == null)))
     {
          ValueValidator.Validate(this, culture, "Email", results, Contact.EmailValidator0, this.Email);
     }
}

Since the validation logic is implemented in the BOM, all upper layers will automatically benefit from it. Furthermore, graphically speaking, validation capabilities are supported in all generated user interfaces we support. Here’s an example of a SharePoint web part generated automatically by our Microsoft SharePoint Producer which displays a validation error message automatically upon a validation error:

image

Note: By the way, the message you’re seeing is the default one, but keep in mind that all validation error messages can be localized globally or specifically per property.

Finally, the generated code also implements automatically two handy interfaces: the standard IDataErrorInfo one, and the custom ICodeFluentSummaryValidator which allows developers to have all validation exceptions in a single list.

Custom Model Reports

March 28, 2011 Leave a comment

Doing a right-click on your CodeFluent Entities project in the solution explorer opens a context menu with a Reports section.

The content of the Reports context menu corresponds to file names from the %ProgramFiles(x86)%\SoftFluent\CodeFluent\Modeler\Templates\Reports directory.

As of today, a single report named Summary is provided out-of-the-box:

SummaryReportMenu

Clicking on it opens a html page containing metrics about your CodeFluent Entities project:

SummaryReport

Reports are in fact CodeFluent Entities templates so you can write your own according to your needs (we actually discussed templates and CodeFluent’s Text Template engine in this previous post).

Since items of the Reports menu come from the Reports folder, to access your custom reports in the Modeler, all you need to do is to place your custom report in this directory.

For instance, let’s copy the Summary.htm template and rename it “My Report.htm”. Here’s what we get when navigating to the Reports menu again:

MyReport

Once you’re there, you can now edit the content of your report template to display whatever you want, the way you want it Smile

CodeFluent Entities Aspects

March 25, 2011 2 comments

CodeFluent Entities Aspects, formerly known as “Patterns”, allow developers to modify and extend the meta-model built by CodeFluent Entities before production. Aspects are platform independent, external to your model and therefore reusable in future developments. Moreover since aspects intervene upstream generation, they have an application-wide, cross-layer scope.

Let’s say a developer wants to add data localization capabilities to his application. CodeFluent Entities actually provides an internationalization aspect named SoftFluent.Localization. This aspect adds localization capabilities to your model by adding a new boolean property named “localizable” which can be set on properties.

image

Once the aspect was added to your project, you can declare a property localizable by selecting it and setting in the property grid the “Is Localizable” property to true.

image

For instance, we added a Description property to the Contact entity, defined as localizable. At generation, but before producers are actually run, the aspect will modify the in-memory representation of the model to add localization support. Technically speaking it will:

· add a ContactLocalized table with an Lcid column and the Description column,

· modify the stored procedures so the localized description column is retrieved as well,

· modify the C# methods to specify the Lcid as a parameter to those stored procedures.

Aspects being external to your model, once you created one, you can reuse it on other applications. Say your applications frequently need tracking capabilities of write operations. You could wrap those up in an aspect, so that you’re investing time to implement such feature once and for all.

Enumeration Support

March 24, 2011 1 comment

CodeFluent Entities fully supports .NET Enumerations, and this support includes:

· Being able to create your own enumerations at design time,

· Use already existing CLR enumerations.

Using our designer, you can create and use enumerations in your model:

image

While actual values of the enum will be used in database, the Business Object Model Producer will generate an actual .NET enumeration.

Likewise you can use any standard CLR enumeration like System.DayOfWeek for instance:

image

Windows Azure Blob Storage Support

March 23, 2011 1 comment

Along with the SQL Azure Producer, the latest CodeFluent Entities build introduced out-of-the-box support for Windows Azure Blob Storage.

Basically, instead of storing your blobs in your database, you can configure your CodeFluent Entities generated application to store them in Windows Azure Blob Storage. You don’t need to generate over, nor to modify your UI code, it is completely independent from the design or modeling phase of your CodeFluent Entities project; and completely independent from the persistence producers used at generation time.

In fact, all you need is:

  • a working Windows Azure Blob Storage account,
  • references to the CodeFluent Azure Runtime (CodeFluent.Runtime.Azure.dll), and Microsoft.Windows.Azure.StorageClient.dll
  • an application configuration file indicating your application should use the Azure binary services instead of the default one.

Check-out this video to see how it goes:

CodeFluent Entities–Windows Azure Blob Storage Support

More information is available in our product documentation here.

Categories: SQLAzure Tags: ,

SQL Azure Producer Overview

March 18, 2011 Leave a comment

As we announced in this post, starting with the build 579, CodeFluent Entities now provides an out-of-the-box SQL Azure Producer.

Using this producer you can generate SQL Azure scripts and automatically run them on your SQL Azure database. Moreover, you can also work on a local SQL Server instance, whilst ensuring you’re using SQL Azure supported features only, and then deploy online when ready. Not only this avoids transfer costs, but when generating over a SQL Server database, the producer’s Diff Engine is enabled which allows you to generate continuously without ever losing data.

Last but not least, the Modeler also ships a new feature known as the Model and Database Explorer which, as the name suggests, lets you explore databases (or XMI and Enterprise Architects models) directly from Visual Studio. Supported databases are: Access 2007/2010, Access / Jet, OLE DB, Oracle, SQL Server, SQL Azure, and SQL Server CE.

This way, once you generated and deployed your scripts on your online SQL Azure database, without leaving Visual Studio you can explore the generated database, including data. Talking about viewing data, unlike Microsoft’s SQL Azure Database Manager, Guids and Blobs can be viewed in the explorer Winking smile

 

Here’s a video showing it all:

SQL Azure Producer Overview
Categories: SQLAzure Tags: , ,

New Online Documentation Release: R10

March 17, 2011 Leave a comment

A new version (R10) of CodeFluent Entities’ documentation was released: http://www.codefluententities.com/documentation/

Extra technical articles were added:

Increased documentation on Search methods, and Array Parameters since CFQL now supports SQL Server 2008’s Table-Valued Types.

The CodeFluent Entities “Pattern” concept was renamed as “Aspect” to avoid confusion.

Documentation on producers was polished and new producer documentation articles were introduced, such as:

Talking about Azure, developers can now configure their application to use Windows Azure Blob Storage to store their blobs instead of storing them in database, and this was documented in a new article as well: Windows Azure Blob Storage.

Categories: Documentation