本文整理汇总了C#中System.Linq.Expressions.MemberExpression.StripForIncludeScanning方法的典型用法代码示例。如果您正苦于以下问题:C# MemberExpression.StripForIncludeScanning方法的具体用法?C# MemberExpression.StripForIncludeScanning怎么用?C# MemberExpression.StripForIncludeScanning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.MemberExpression
的用法示例。
在下文中一共展示了MemberExpression.StripForIncludeScanning方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitMemberAccess
protected override Expression VisitMemberAccess(MemberExpression memberExpression)
{
MemberExpression expression;
var visited = new List<MemberExpression>();
var root = memberExpression.Expression.StripForIncludeScanning();
var memberIsDataAccessObjectGatheringForProjection = false;
// Don't perform implicit joins for RelatedDataAccessObject collections as those currently turn into N+1 queries
if (this.nesting < 1 && (memberExpression.Type.GetSequenceElementType()?.IsDataAccessObjectType() ?? false))
{
return base.VisitMemberAccess(memberExpression);
}
if (memberExpression.Type.IsTypeRequiringJoin())
{
if (this.forProjection)
{
memberIsDataAccessObjectGatheringForProjection = true;
expression = memberExpression.StripForIncludeScanning() as MemberExpression;
}
else
{
expression = memberExpression.Expression.StripForIncludeScanning() as MemberExpression;
if (expression == null || !expression.Expression.StripForIncludeScanning().Type.IsTypeRequiringJoin())
{
return memberExpression;
}
}
}
else
{
if (memberExpression.Expression?.StripForIncludeScanning() == null)
{
return memberExpression;
}
var typeDescriptor = this.model.TypeDescriptorProvider.GetTypeDescriptor(memberExpression.Expression.StripForIncludeScanning().Type);
if (typeDescriptor == null)
{
return Expression.MakeMemberAccess(this.Visit(memberExpression.Expression.StripForIncludeScanning()), memberExpression.Member);
}
var property = typeDescriptor.GetPropertyDescriptorByPropertyName(memberExpression.Member.Name);
if (property.IsPrimaryKey && memberExpression.Expression.StripForIncludeScanning() is MemberExpression)
{
expression = ((MemberExpression)memberExpression.Expression.StripForIncludeScanning()).Expression.StripForIncludeScanning() as MemberExpression;
}
else
{
expression = memberExpression.Expression.StripForIncludeScanning() as MemberExpression;
}
}
var currentExpression = expression.StripForIncludeScanning() as MemberExpression;
while (currentExpression?.Member is PropertyInfo)
{
visited.Add(currentExpression);
root = currentExpression.Expression.StripForIncludeScanning();
currentExpression = root as MemberExpression;
if (currentExpression == null)
{
root = this.GetExpression(root).StripForIncludeScanning();
currentExpression = root as MemberExpression;
}
}
var includedPathSkip = 0;
var i = 0;
foreach (var current in visited)
{
if (!current.Member.ReflectedType.IsTypeRequiringJoin()
|| current == this.currentParent /* @see: Test_Select_Project_Related_Object_And_Include1 */)
{
includedPathSkip = visited.Count - i;
break;
}
i++;
}
visited.Reverse();
i = 0;
currentExpression = expression;
while (currentExpression?.Member is PropertyInfo)
{
var path = new PropertyPath(c => c.Name, visited.Select(c=> (PropertyInfo)c.Member).Take(visited.Count - i).ToArray());
//.........这里部分代码省略.........