Release notes for re-motion version 1.13.80

List of Issues

New Features

Details

[RM-3399] SQL Backend: Allow method call transformers to be specified via custom attributes

Component/s: Data.Linq
Issue Type: New Feature
Resolution: Fixed
Status: Closed


Allow classes such as the following to be written:

public class MyEntity
{
  ...

  [MethodCallTransformer (typeof (MyMethodCallTransformer))]
  public int GetFoo()
  {
    return ...;
  }
}

This will cause the Linq transformer to detect GetFoo() as a method to be handled by the MyMethodCallTransformer.

The MethodCallTransformerAttribute can also be applied to the getter methods of property declarations:

public class MyEntity
{
  ...

  public int Foo
  {
    [MethodCallTransformer (typeof (MyMethodCallTransformer))]
    get { return ...; }
  }
}

The handler indicated by the custom attribute is invoked while translating the LINQ query to SQL the same way as a handler registered in the MethodCallTransformerRegistry would be. While MethodCallTransformerRegistry is usually employed by the LINQ provider itself to register handlers for predefined methods and properties, the attribute-based mechanism complements that by allowing the person writing a class used in a LINQ query (usually an entity class) to specify how the class' methods and properties should be handled.

The MethodCallTransformerAttribute is evaluated only if not MethodInfo-based transformer registration is found, but it can be used to override name-based transformer registrations.

Besides the predefined MethodCallTransformerAttribute, re-linq users can also write their own custom attributes implementing IMethodCallTransformerAttribute in order to implement custom transformations.