Nermin's .Net

My Thoughts on .Net and Software Development - correct spelling is optional

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Using Lambda Expressions in Csla.Net property registration

With Csla.Net 3.5 came a concept of "managed properties", properties that automatically handle business and authorization rules, without additional code reguired to wire up all those notifications.  In 3.6 managed properties were extended to allow serializing Csla.Net objects accross different runtimes (.Net to Silverlght).

The thing I do not like about property registration was, while it resembled dependency properties from WP/Silverlight, it required string constants or property names.  And string constants as we know are BAAD! 

So, in 3.6.2 we are adding another way to register properties - using Linq Expression API!  Lets take a look at the example:

    private static PropertyInfo DescriptionProperty = 
      RegisterProperty(p=>p.Description);
    public string Description
    {
      get { return GetProperty(DescriptionProperty); }
      set { SetProperty(DescriptionProperty, value); }
    }

Besides being shorter, this syntax supports full Intellisense, as the only expressions allowed are Property expressions of properties belonging to the object. This is compile time safe.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by ndibek on Wednesday, March 04, 2009 1:23 PM
Permalink | Comments (1367) | Post RSSRSS comment feed

Comments