Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / XML

QueryMap: Custom Translation of LINQ Expressions

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
22 Apr 2012Ms-PL9 min read 36.3K   441   7  
QueryMap allows you to pre-translate a LINQ expression into a form that the underlying query provider (such as LINQ to SQL) can understand.
namespace Overboard.Linq {
    using System;

    partial class Person {
        internal DateTime MinimumRetirementDateUnmapped {
            get { return _minimumRetirementDateExpression.Invoke(this); }
        }

        [MapToExpression("BadMap")]
        internal DateTime MinimumRetirementDateBadMapName {
            get { return _minimumRetirementDateExpression.Invoke(this); }
        }

        [MapToExpression("_minimumRetirementDateExpression")]
        internal DateTime MinimumRetirementDateToFieldExpression {
            get { return _minimumRetirementDateExpression.Invoke(this); }
        }

        [MapToExpression("_minimumRetirementDateLambda")]
        internal DateTime MinimumRetirementDateToFieldLambda {
            get { return MinimumRetirementDateToFieldExpression; }
        }

        [MapToExpression("MinimumRetirementDateExpression")]
        internal DateTime MinimumRetirementDateToPropertyExpression {
            get { return _minimumRetirementDateExpression.Invoke(this); }
        }

        [MapToExpression("MinimumRetirementDateLambda")]
        internal DateTime MinimumRetirementDateToPropertyLambda {
            get { return MinimumRetirementDateToPropertyExpression; }
        }

        [MapToExpression("GetMinimumRetirementDateExpression")]
        internal DateTime MinimumRetirementDateToMethodExpression {
            get { return _minimumRetirementDateExpression.Invoke(this); }
        }

        [MapToExpression("GetMinimumRetirementDateLambda")]
        internal DateTime MinimumRetirementDateToMethodLambda {
            get { return MinimumRetirementDateToMethodExpression; }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior)
United States United States
David Nelson has been programming in various languages for 17 years, and has been programming in .NET (C# and VB.NET) since 2003.
He is a MCTS in .NET 2.0 Web Applications, and is a moderator on the MSDN Forums (http://forums.microsoft.com/msdn).

Comments and Discussions