Beispiel #1
0
 internal static Expression TranslateAssociation(DataContext context, MetaAssociation association, Expression otherSource, Expression[] keyValues, Expression thisInstance)
 {
     if (association == null)
     {
         throw Error.ArgumentNull("association");
     }
     if (keyValues == null)
     {
         throw Error.ArgumentNull("keyValues");
     }
     if (context.LoadOptions != null)
     {
         LambdaExpression associationSubquery = context.LoadOptions.GetAssociationSubquery(association.ThisMember.Member);
         if (associationSubquery != null)
         {
             var composer = new RelationComposer(associationSubquery.Parameters[0], association, otherSource, thisInstance);
             return(composer.Visit(associationSubquery.Body));
         }
     }
     return(WhereClauseFromSourceAndKeys(otherSource, association.OtherKey.ToArray <MetaDataMember>(), keyValues));
 }
        /// <summary>
        /// Create an Expression representing the given association and key value expressions.
        /// </summary>
        internal static Expression TranslateAssociation(DataContext context, MetaAssociation association, Expression otherSource, Expression[] keyValues, Expression thisInstance) {
            if (association == null)
                throw Error.ArgumentNull("association");
            if (keyValues == null)
                throw Error.ArgumentNull("keyValues");

            if (context.LoadOptions!=null) {
                LambdaExpression subquery = context.LoadOptions.GetAssociationSubquery(association.ThisMember.Member);
                if (subquery!=null) {
                    RelationComposer rc = new RelationComposer(subquery.Parameters[0], association, otherSource, thisInstance);
                    return rc.Visit(subquery.Body);
                }
            }
            return WhereClauseFromSourceAndKeys(otherSource, association.OtherKey.ToArray(), keyValues);
        }