本文整理汇总了C#中System.Linq.Expressions.MemberExpression.GetDepth方法的典型用法代码示例。如果您正苦于以下问题:C# MemberExpression.GetDepth方法的具体用法?C# MemberExpression.GetDepth怎么用?C# MemberExpression.GetDepth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.MemberExpression
的用法示例。
在下文中一共展示了MemberExpression.GetDepth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddInclude
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));
}
}
}