本文整理汇总了C#中SelectExpression.SetColumns方法的典型用法代码示例。如果您正苦于以下问题:C# SelectExpression.SetColumns方法的具体用法?C# SelectExpression.SetColumns怎么用?C# SelectExpression.SetColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectExpression
的用法示例。
在下文中一共展示了SelectExpression.SetColumns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitSelect
protected override Expression VisitSelect(SelectExpression select)
{
select = (SelectExpression) base.VisitSelect(select);
// look for redundant column declarations
List<ColumnDeclaration> cols = select.Columns.OrderBy(c => c.Name).ToList();
BitArray removed = new BitArray(select.Columns.Count);
bool anyRemoved = false;
for (int i = 0, n = cols.Count; i < n - 1; i++)
{
ColumnDeclaration ci = cols[i];
ColumnExpression cix = ci.Expression as ColumnExpression;
QueryType qt = cix != null ? cix.QueryType : ci.QueryType;
ColumnExpression cxi = new ColumnExpression(ci.Expression.Type, qt, select.Alias, ci.Name);
for (int j = i + 1; j < n; j++)
{
if (!removed.Get(j))
{
ColumnDeclaration cj = cols[j];
if (SameExpression(ci.Expression, cj.Expression))
{
// any reference to 'j' should now just be a reference to 'i'
ColumnExpression cxj = new ColumnExpression(cj.Expression.Type, qt, select.Alias, cj.Name);
this.map.Add(cxj, cxi);
removed.Set(j, true);
anyRemoved = true;
}
}
}
}
if (anyRemoved)
{
List<ColumnDeclaration> newDecls = new List<ColumnDeclaration>();
for (int i = 0, n = cols.Count; i < n; i++)
{
if (!removed.Get(i))
{
newDecls.Add(cols[i]);
}
}
select = select.SetColumns(newDecls);
}
return select;
}