Property name inference

edit

Appending suffixes to a lambda expression body

edit

Suffixes can be appended to the body of a lambda expression, which is useful in cases where you have a POCO property mapped as a multi-field and want to use strongly typed access with a lambda expression, yet append a suffix to the generated field name, in order to access a particular sub field of the multi-field.

The .Suffix() extension method can be used for this purpose and when serializing expressions suffixed in this way, the serialized property name resolves to the last token

Expression<Func<Project, object>> expression = p => p.Name.Suffix("raw");
Expect("raw").WhenSerializing<PropertyName>(expression);

Appending suffixes to a Lambda expression

edit

Alternatively, suffixes can be applied to a lambda expression directly using the .ApplySuffix() extension method. Again, the serialized field name resolves to the last token

Expression<Func<Project, object>> expression = p => p.Name;
expression = expression.AppendSuffix("raw");
Expect("raw").WhenSerializing<PropertyName>(expression);