We're updating the issue view to help you get more done. 

Provide transformations that add member meta-info to common tuple-like constructor calls

Description

Consider the following example (from http://groups.google.com/group/nhusers/browse_thread/thread/7289619c4eceaf2b):

1 2 3 from u in db.Users select new KeyValuePair<string, DateTime>(u.Name, u.RegisteredAt) into nameRegistered order by nameRegistered.Value

The provider cannot know that u.Name goes into nameRegistered.Value. To allow for that, add a custom transformation that adds the metadata to the ctor call:

1 2 3 4 NewExpression ( ctorof (KeyValuePair<TK,TV>(TK,TV)), new[] { keyExpr, valueExpr }, new[] { memberof (KeyValuePair<TK,TV>.Key), memberof (KeyValuePair<TK,TV>.Value) })

Transformations such as the one described above are added a set of classes: KeyValuePairNewExpressionTransformer, and DictionaryEntryTransformer, and TupleNewExpressionTransformer, The transformations, which are enabled by default, add the MemberInfo metadata to NewExpressions for KeyValuePair<TKey, TValue>, DictionaryEntry, and the .NET Tuple types.

To implement such a transformation for custom types, derive from MemberAddingNewExpressionTransformerBase.

For LINQ providers customizing the expression tree preprocessing steps applied by the re-linq front-end, add instances of the transformer classes to the ExpressionTransformationStep.

Status

Assignee

Fabian Schmied

Reporter

Labels

Time tracking

2h

Components

Fix versions

Priority

Normal