Example #1
0
 private void AddInclude(SimpleType source, MemberExpression memberSelector, LambdaExpression collectionInclude)
 {
     var members = source.GetAllMembers();
     if (members.Count > 0 && memberSelector.GetDepth() > 1)
     {
         var innermostMember = ExpressionUtil.GetInnermostMemberExpression(memberSelector);
         foreach (var kvp in members)
         {
             if (kvp.Key == innermostMember.Member)
             {
                 AddInclude(kvp.Value, ExpressionUtil.ReplaceInnermostMemberExpressionWithParameter(memberSelector) as MemberExpression, collectionInclude);
                 return;
             }
         }
     }
     else
     {
         var parameter = ExpressionUtil.GetParameterExpression(memberSelector);
         if (collectionInclude != null)
         {
             source.Includes.Add(IncludeDirectiveUtil.GetIncludeInCollectionDirective(memberSelector, collectionInclude));
         }
         else
         {
             source.Includes.Add(IncludeDirectiveUtil.GetIncludeDirective(memberSelector));
         }
     }
 }