Home » Blog

rounded header

Archive for January, 2009

DTOs, Data Contacts and code generation

tag icon Tagged as LightSpeed, Products

Recently a new LightSpeed customer asked about adding code generation support for creating data transfer objects (DTOs) and code to help in sending LightSpeed entities over the wire. Further to this, Jeremy recently posted a guide to working with WCF and LightSpeed due to an increasing interest in working with LightSpeed in distributed environments.

So we set about adding this type of code generation and it is now available in the LightSpeed nightly builds (grab a copy here).

What code gets generated?

For each entity, a DTO decorated with WCF attributes:

[System.Runtime.Serialization.DataContract(Name="Customer")]
public partial class CustomerDto
{
  [System.Runtime.Serialization.DataMember]
  public string Username { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string FirstName { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string LastName { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string Address1 { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string Suburb { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string City { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string Country { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string Phone { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string Email { get; set; }
  [System.Runtime.Serialization.DataMember]
  public string Address2 { get; set; }
}

An extension method to convert the entity to its associated DTO:

public static CustomerDto AsDto(this Customer entity)
{
  return new CustomerDto
  {
    Username = entity.Username,
    FirstName = entity.FirstName,
    LastName = entity.LastName,
    Address1 = entity.Address1,
    Suburb = entity.Suburb,
    City = entity.City,
    Country = entity.Country,
    Phone = entity.Phone,
    Email = entity.Email,
    Address2 = entity.Address2,
  };
}

An extension method to convert the DTO to it’s associated entity:

public static Customer CopyTo(this CustomerDto source, Customer entity)
{
  entity.Username = source.Username;
  entity.FirstName = source.FirstName;
  entity.LastName = source.LastName;
  entity.Address1 = source.Address1;
  entity.Suburb = source.Suburb;
  entity.City = source.City;
  entity.Country = source.Country;
  entity.Phone = source.Phone;
  entity.Email = source.Email;
  entity.Address2 = source.Address2;
  return entity;
}

As you can see, this saves a huge amount of code that would be tedious for you to write and therefore fits the purpose of our products – to help you get more done, faster.

How do to this?

If you’re already a LightSpeed user, grab the latest nightly so that the designer includes this feature.

  • First off, fire up Visual Studio and create a project for your model.
  • Add references to System.ServiceModel and System.Runtime.Serialization (this is important, the designer will only generate this code if it detects you’re working with WCF)
  • Create your model as you normally would, hit save. If you have an existing model, open it and save it.
  • Done!

We always appreciate getting feedback about what features would help you. If there’s something we could generate to save you some coding effort then leave us a comment.

Screencast: Working with Views in LightSpeed

Mindscape Screencast

Yet another how-to screencast on working with LightSpeed, we have just published “Views with LightSpeed”.

LightSpeed has always supported working with Views however with LightSpeed 2.2 we have added many enhancements to make them easier to work with. This video helps explore what new additions have been made to improve the developer experience when working with views.

With this screencast you will learn:

  • How to easily work with views in the LightSpeed Visual Studio Designer
  • How to query against views – both with the generated IQueryable and the LightSpeed classic query API
  • How to deal with views that are projections of tables rather than matching existing entities
  • How to with views that return projections that do not match existing entities
  • When having an updatable view would be useful.

Click here to watch how to use Views with LightSpeed.

We added improved view support to LightSpeed for version 2.2 (and in the nightly builds following 2.1). Grab a copy of the latest build of LightSpeed that includes this support here.

Any feedback – either on the view support of on the screencast itself, is greatly appreciated. Drop a comment on this post.

WPF Flow Diagrams beta

NOTE: This product has now come out of beta, and is available on the site. Add a WPF Flow Diagram to your application with the free trial.

We’re pleased to announce the beta for our new WPF Flow Diagrams product. WPF Flow Diagrams is a toolkit for adding flow diagramming functionality to Windows Presentation Foundation applications. As befits a WPF component, it provides extensive support for customisation and styling as well as a standard “out of the box” look.

Here’s an example from the QuickStart sample included with the beta:

Flow Diagrams quick start

And of course you can theme it up: here’s the same diagram using a different style including a custom graph-paper-like background:

Same diagram with alternate style

And Jason offers a tribute to xkcd:

The geek force is strong in this one

We’ll be posting more articles in the near future about how to create and style diagrams using the WPF Flow Diagrams toolkit, but in the meantime, take the beta out for a spin and see what you can create!

Screencast: Stored Procedures with LightSpeed

Mindscape Screencast

In our ongoing series of screencasts, we now have a guide to working with Stored Procedures with LightSpeed.

With this screencast you will learn:

  • How to easily work with stored procedures with the LightSpeed Visual Studio Designer
  • How to work with custom parameters to your stored procedures (as OUT or REF parameters for example)
  • How to write your own ProcedureQuery’s if you don’t wish to use the designer
  • How to work with ProcedureParameter’s
  • Some tips and tricks when working with stored procedures that return projections that do not match existing entities

Click here to watch how to use Stored Procedures with LightSpeed.

We added Stored Procedure support to LightSpeed for version 2.2 (and in the nightly builds following 2.1) and supports working with stored procedures in SQL Server, Oracle and MySQL. Grab a copy of the latest build of LightSpeed that includes this support here.

Any feedback – either on the stored procedure support of on the screencast itself, is greatly appreciated. Drop a comment on this post.

Making LightSpeed easier to learn

tag icon Tagged as LightSpeed, Products

A few posts back I commented that we’re always trying to improve the ease of use of our products. I focused on LightSpeed and will do so again here because we’re rapidly approaching the 2.2 release.

Mindscape is a very developer focused company, the aim has always been to make our tools as easy as possible to pick up and learn. The learning curve of a product often can have a direct impact on if it’s worth investing in the tool at all or, worse, if it takes too long to realise the benefits of the tools then users give up in frustration (and rightly so!).

Starting in LightSpeed 2.2 we will be adding additional documentation directly inside Visual Studio to explain the next steps required to deliver solutions on LightSpeed. Here’s an early screenshot of a very unstyled but ultimately helpful guide for first time users (we will be making it more attractive):

Getting started screenshot

WOW – A text file! But seriously, what is nice about this is that the configuration and code reflects the information about your model. So copying and pasting, for example, the configuration section, will result in a block of xml that includes your connection string and database provider already configured. One less thing to worry about.

The idea here is that first time users tend to use the LightSpeed designer to create a model and then wonder what they need to do next. At the moment we’re working on how we make displaying this screen obvious in the designer without getting in the way of people who are quite experienced and don’t want to see it (although so far we have seen that even experienced users find it useful because they can copy and paste the boiler plate config without needing to check previous projects or documentation).

What else could we add to help you get started more easily?

Data Products Visual Controls Community Store
LightSpeed ORM
NHibernate Designer
SimpleDB Tools
SharePoint Tools
WPF Elements
WPF Diagrams
Silverlight Elements
Forums
Blog
Register
Login
Subscribe to newsletter
Buy Now
My Account
Volume Discounts
Purchase Orders
Contact Us