LightSpeed 1.2 Released

We’re pleased to announce the release of LightSpeed 1.2. This is a major update and includes many new features, tools, optimizations and fixes to hopefully make your LightSpeed development experience easier and even more enjoyable! Here are the highlights and keep reading for a sneak peak of what’s coming in LightSpeed 2.0

h3. Property Name Inference

For performance reasons and ease of debugging (as well as our own general penchant for simplicity) LightSpeed forgoes the use of dynamic proxies. Before 1.2 this meant that you would have to specify property names inside getters and setters so that the framework could keep track of property changes. However, after some help from one of New Zealand’s smartest devs, we now have an approach that means the string property names are no longer required.

Before the code looked like this:

public string Surname
{
  get { return _surname; }
  set { Set(ref _surname, value, "Surname"); }
}

Now it just looks like this:

public string Surname
{
  get { return _surname; }
  set { Set(ref _surname, value); }
}

We still expose an overload that takes a property name which can be used from code gen and will be slightly faster than omitting the property name.

h3. Value Object Lazy Loading

LightSpeed now supports lazy-loading value objects (in LightSpeed a value object is either a simple value type field or a field decorated with the _ValueObject_ attribute). This is particularly useful for blob attributes or other expensive or infrequently accessed fields. We implemented this by integrating into our _Named Aggregate_ system like so:

public class Contribution : Entity<int>
{
  [EagerLoad(AggregateName = "ContributionDetail")]  
  public byte[] _data;
 
  public byte[] Data
  {
    get { return Get(ref _data); }
    set { Set(ref _data, value); }
  }
}

By applying the _EagerLoad_ attribute with a _Named Aggregate_ we’re effectively making the field lazy (unless, of course, we specify the aggregate name as part of our query). Additionally, note the use of the _Get_ method in the property getter. This ensures that the field will be lazy loaded on first request.

h3. One-to-One Associations

By popular demand 1.2 includes support for one-to-one associations. We spent a bit of time getting this to work without any API changes and so we simply end up with our standard ValueHolder pattern:

 
public sealed class Car : Entity<int>
{
  private readonly EntityHolder<Engine> _engine
    = new EntityHolder<Engine>();
 
  public Engine Engine
  {
    get { return Get(_engine); }
    set { Set(_engine, value); }
  }
}
 
public sealed class Engine : Entity<int>
{
  private int? _carId;
 
  private readonly EntityHolder<Car> _car
    = new EntityHolder<Car>();
 
  public int? CarId
  {
    get { return Get(ref _carId); }
    set { Set(ref _carId, value); }
  }
 
  public Car Car
  {
    get { return Get(_car); }
    set { Set(_car, value); }
  }
}

h3. More Mapping Options

We’ve included a couple of new attributes that provide more fine-grained control over class to table mapping. _TableAttribute_ and _ColumnAttribute_ allow custom table and column names to be specified respectively, Additionally, _TableAttribute_ also allows a custom primary key column name to be declared. Be clear, LightSpeed is still very much a convention-over-configuration style framework and it was a conscious decision to only add these configuration points now. Use judiciously.

[Table("GadgetsTable", IdColumnName = "Code")]
public class Gadget : Entity<int>
{
  [Column("Name")]
  private string _title;
 
  //...
}

h3. More Load Hooks

A couple of customers wanted some more hooks around object load. You ask and we deliver! Override _BeforeLoad_ and _AfterLoad_ to have your way with an Entity as it’s being loaded.

h3. CreatedOn and UpdatedOn

We also added a couple more “convention fields”: _CreatedOn_ and _UpdatedOn_ provide simple client-side timestamping – Great for keeping your database clean of application logic.

// MyClass.cs
 
private readonly DateTime _createdOn = DateTime.MinValue;
 
public DateTime CreatedOn
{
  get { return _createdOn; }
}
 
private readonly DateTime _updatedOn = DateTime.MinValue;
 
public DateTime UpdatedOn
{
  get { return _updatedOn; }
}

h3. Postgres, MySQL and SQLite Auto-Increment Columns

Even though some consider identity columns to be about as evil as The Spawn of Xenu, we at Mindscape aim to cater to all denominations. So LightSpeed 1.2 improves support for identity columns by enabling the various flavours offered by Postgres, MySQL and SQLite. Be aware: using Identity columns in .NET is slower than other approaches.

h3. Debugger Visualizer

LightSpeed 1.2 includes a new Debugger Visualizer allowing easy viewing of query SQL. Just drop _Mindscape.LightSpeed.DebuggerVisualizer.dll_ into one of your Visual Studio visualizers folders and you can bask in the beauty of queries such as this bad boy:

LightSpeed Debugger Visualizer

Don’t worry, this is just one from our test suite. Your results may vary.

h3. Localization Sample

Finally, we created a small sample illustrating how to override LightSpeed’s default resource set. Great for multi-language or even just customizing some of the framework’s validation and error messages.

h3. Roadmap

We’re hard at work on our LightSpeed LINQ provider which we’ll be releasing as a core feature of LightSpeed 2.0. Other features that might make it into 2.0 include: Migrations, Nested Sets, Code Generation, N-Level Undo and more. We would also love to know what you’d like to see so feel free to tell us. We’re very keen to get LightSpeed 2.0 out sooner rather than later so expect to see this in the next few months.

Cheers,

The Mindscape Team.

kick it on DotNetKicks.com

Tagged as LightSpeed, Products

5 Responses to “LightSpeed 1.2 Released”

Archives

Join our mailer

You should join our newsletter! Sent monthly:

Back to Top