本文整理汇总了C#中ColumnExpression类的典型用法代码示例。如果您正苦于以下问题:C# ColumnExpression类的具体用法?C# ColumnExpression怎么用?C# ColumnExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnExpression类属于命名空间,在下文中一共展示了ColumnExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddOuterJoinTest
public virtual ProjectionExpression AddOuterJoinTest(ProjectionExpression proj)
{
var test = this.GetOuterJoinTest(proj.Select);
var select = proj.Select;
ColumnExpression testCol = null;
// look to see if test expression exists in columns already
foreach (var col in select.Columns)
{
if (test.Equals(col.Expression))
{
var colType = SqlType.Get(test.Type);
testCol = new ColumnExpression(test.Type, colType, select.Alias, col.Name);
break;
}
}
if (testCol == null)
{
// add expression to projection
testCol = test as ColumnExpression;
string colName = (testCol != null) ? testCol.Name : "Test";
colName = proj.Select.Columns.GetAvailableColumnName(colName);
var colType = SqlType.Get(test.Type);
select = select.AddColumn(new ColumnDeclaration(colName, test, colType));
testCol = new ColumnExpression(test.Type, colType, select.Alias, colName);
}
var newProjector = new OuterJoinedExpression(testCol, proj.Projector);
return new ProjectionExpression(select, newProjector, proj.Aggregator);
}
示例2: GroupByExpression
public GroupByExpression(ColumnExpression simpleGroup, Expression keyExpression)
: base(ExpressionType, simpleGroup.Table)
{
SimpleGroup = simpleGroup;
HasKey = false;
KeyExpression = keyExpression;
Table = SimpleGroup.Table;
}
示例3: VisitColumn
protected override Expression VisitColumn(ColumnExpression column)
{
if (this.oldAliases.Contains(column.Alias))
{
return new ColumnExpression(column.Type, column.SqlType, this.newAlias, column.Name);
}
return column;
}
示例4: UpdateColumnAssignment
protected ColumnAssignment UpdateColumnAssignment(ColumnAssignment ca, ColumnExpression c, Expression e)
{
if (c != ca.Column || e != ca.Expression)
{
return new ColumnAssignment(c, e);
}
return ca;
}
示例5: VisitColumn
protected override Expression VisitColumn(ColumnExpression column)
{
TableAlias newAlias;
if (this.map.TryGetValue(column.Alias, out newAlias))
{
return new ColumnExpression(column.Type, newAlias, column.Name);
}
return column;
}
示例6: VisitColumn
protected override Expression VisitColumn(ColumnExpression column)
{
if (column.Alias != null)
{
sb.AppendFormat("`{0}`", GetAliasName(column.Alias));
sb.Append(".");
}
sb.AppendFormat("`{0}`", column.Name);
return column;
}
示例7: VisitColumn
protected override Expression VisitColumn(ColumnExpression column)
{
if (column.Alias != null)
{
sb.AppendFormat("{0}", GetAliasName(column.Alias));
sb.Append("."); //MAA,20091127: remove quotes in column names
//sb.Append(".\"");
}
sb.AppendFormat("{0}", column.Name);
//sb.Append("\"");//MAA,20091127: remove quotes in column names
return column;
}
示例8: VisitSelect
protected override Expression VisitSelect(SelectExpression select)
{
select = (SelectExpression)base.VisitSelect(select);
if (select.Skip != null)
{
SelectExpression newSelect = select.SetSkip(null).SetTake(null);
bool canAddColumn = !select.IsDistinct && (select.GroupBy == null || select.GroupBy.Count == 0);
if (!canAddColumn)
{
newSelect = newSelect.AddRedundantSelect(new TableAlias());
}
var colType = DbTypeSystem.GetColumnType(typeof(int));
newSelect = newSelect.AddColumn(new ColumnDeclaration(columnName, new RowNumberExpression(select.OrderBy), colType));
// add layer for WHERE clause that references new rownum column
newSelect = newSelect.AddRedundantSelect(new TableAlias());
newSelect = newSelect.RemoveColumn(newSelect.Columns.Single(c => c.Name == columnName));
var newAlias = ((SelectExpression)newSelect.From).Alias;
ColumnExpression rnCol = new ColumnExpression(typeof(int), colType, newAlias, columnName);
Expression where;
if (select.Take != null)
{
where = new BetweenExpression(
rnCol, Expression.Add(select.Skip, Expression.Constant(1)), Expression.Add(select.Skip, select.Take));
}
else
{
where = rnCol.GreaterThan(select.Skip);
}
if (newSelect.Where != null)
{
where = newSelect.Where.And(where);
}
newSelect = newSelect.SetWhere(where);
select = newSelect;
}
return select;
}
示例9: WriteColumnExpression
public override bool WriteColumnExpression(ColumnExpression node)
{
if (ResolveNames)
{
Expression ex = node.FindDescendant<Expression>();
WriteNode(ex);
if (!String.IsNullOrEmpty(node.ColumnReference.ColumnAlias))
{
Writer.Write(" AS {0}", QuoteIdentifier(node.ColumnReference.ColumnAlias));
}
return false;
}
else
{
return true;
}
}
示例10: 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;
}
示例11: MakeSubquery
private Expression MakeSubquery(Expression expression)
{
var newAlias = new TableAlias();
var aliases = DeclaredAliasGatherer.Gather(expression);
var decls = new List<ColumnDeclaration>();
foreach (var ta in aliases)
{
foreach (var col in this.columns[ta])
{
string name = decls.GetAvailableColumnName(col.Name);
var decl = new ColumnDeclaration(name, col, col.QueryType);
decls.Add(decl);
var newCol = new ColumnExpression(col.Type, col.QueryType, newAlias, col.Name);
this.map.Add(col, newCol);
}
}
return new SelectExpression(newAlias, decls, expression, null);
}
示例12: ResolveColumn
private ColumnExpression ResolveColumn(ColumnExpression ce, SelectExpression select)
{
if (ce.Alias == select.Alias)
{
var cd = select.Columns.SingleEx(a => a.Name == ce.Name);
var result = cd.Expression as ColumnExpression;
if(result == null)
return ce;
TableExpression table = (TableExpression)select.From;
if (table.Alias == result.Alias)
{
return new ColumnExpression(result.Type, aliasGenerator.Table(table.Name), result.Name);
}
return result;
}
return ce;
}
示例13: VisitColumn
protected override Expression VisitColumn(ColumnExpression column)
{
if (column.Alias != null && !this.HideColumnAliases)
{
this.WriteAliasName(GetAliasName(column.Alias));
this.Write(".");
}
this.WriteColumnName(column.Name);
return column;
}
示例14: VisitColumn
protected virtual Expression VisitColumn(ColumnExpression column)
{
int iAlias;
string aliasName =
this.aliasMap.TryGetValue(column.Alias, out iAlias)
? "A" + iAlias
: "A" + (column.Alias != null ? column.Alias.GetHashCode().ToString() : "") + "?";
this.Write(aliasName);
this.Write(".");
this.Write("Column(\"");
this.Write(column.Name);
this.Write("\")");
return column;
}
示例15: VisitColumn
protected override Expression VisitColumn(ColumnExpression column)
{
MarkColumnAsUsed(column.Alias, column.Name);
return column;
}