本文整理汇总了C#中ColumnExpression类的典型用法代码示例。如果您正苦于以下问题:C# ColumnExpression类的具体用法?C# ColumnExpression怎么用?C# ColumnExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColumnExpression类属于命名空间,在下文中一共展示了ColumnExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:jaykizhou,项目名称:elinq,代码行数:28,代码来源:DbExpressionBuilder.cs
示例2: GroupByExpression
public GroupByExpression(ColumnExpression simpleGroup, Expression keyExpression)
: base(ExpressionType, simpleGroup.Table)
{
SimpleGroup = simpleGroup;
HasKey = false;
KeyExpression = keyExpression;
Table = SimpleGroup.Table;
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:GroupByExpression.cs
示例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;
}
开发者ID:nikhel,项目名称:elinq,代码行数:8,代码来源:ColumnMapper.cs
示例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;
}
开发者ID:bisand,项目名称:NetCouch,代码行数:8,代码来源:DbExpressionVisitor.cs
示例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;
}
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:9,代码来源:QueryDuplicator.cs
示例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;
}
开发者ID:6nop,项目名称:SubSonic-3.0,代码行数:10,代码来源:SQLiteFormatter.cs
示例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;
}
开发者ID:mabraham1,项目名称:LINQ2Oracle,代码行数:12,代码来源:OracleFormatter.cs
示例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;
}
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm.Linq,代码行数:45,代码来源:SkipToRowNumberRewriter.cs
示例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;
}
}
开发者ID:horvatferi,项目名称:graywulf,代码行数:18,代码来源:MySqlCodeGenerator.cs
示例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;
}
开发者ID:lepigocher,项目名称:iqtoolkit-oracle,代码行数:44,代码来源:RedundantColumnRemover.cs
示例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);
}
开发者ID:RukaiYu,项目名称:EnterpriseDevelopmentFx,代码行数:20,代码来源:CrossJoinIsolator.cs
示例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;
}
开发者ID:signumsoftware,项目名称:framework,代码行数:23,代码来源:UpdateDeleteSimplifier.cs
示例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;
}
开发者ID:firestrand,项目名称:IQToolkit,代码行数:10,代码来源:SqlFormatter.cs
示例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;
}
开发者ID:nikhel,项目名称:elinq,代码行数:15,代码来源:DbExpressionWriter.cs
示例15: VisitColumn
protected override Expression VisitColumn(ColumnExpression column)
{
MarkColumnAsUsed(column.Alias, column.Name);
return column;
}
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:5,代码来源:UnusedColumnRemover.cs
示例16: GetIdentityCheck
private Expression GetIdentityCheck(TableExpression root, MappingEntity entity, Expression instance, MappingTable table)
{
if (this.mapping.IsExtensionTable(table))
{
var keyColNames = this.mapping.GetExtensionKeyColumnNames(table).ToArray();
var relatedMembers = this.mapping.GetExtensionRelatedMembers(table).ToArray();
Expression where = null;
for (int i = 0, n = keyColNames.Length; i < n; i++)
{
var relatedMember = relatedMembers[i];
var cex = new ColumnExpression(TypeHelper.GetMemberType(relatedMember), this.GetColumnType(entity, relatedMember), root.Alias, keyColNames[n]);
var nex = this.GetMemberExpression(instance, entity, relatedMember);
var eq = cex.Equal(nex);
where = (where != null) ? where.And(eq) : where;
}
return where;
}
else
{
return base.GetIdentityCheck(root, entity, instance);
}
}
开发者ID:rdrawsky,项目名称:iqtoolkit,代码行数:23,代码来源:AdvancedMapping.cs
示例17: GetDependentGeneratedVariableDeclaration
// make a variable declaration / initialization for dependent generated values
private CommandExpression GetDependentGeneratedVariableDeclaration(MappingEntity entity, MappingTable table, List<MemberInfo> members, Expression instance, Dictionary<MemberInfo, Expression> map)
{
// first make command that retrieves the generated ids if any
DeclarationCommand genIdCommand = null;
var generatedIds = this.mapping.GetMappedMembers(entity).Where(m => this.mapping.IsPrimaryKey(entity, m) && this.mapping.IsGenerated(entity, m)).ToList();
if (generatedIds.Count > 0)
{
genIdCommand = this.GetGeneratedIdCommand(entity, members, map);
// if that's all there is then just return the generated ids
if (members.Count == generatedIds.Count)
{
return genIdCommand;
}
}
// next make command that retrieves the generated members
// only consider members that were not generated ids
members = members.Except(generatedIds).ToList();
var tableAlias = new TableAlias();
var tex = new TableExpression(tableAlias, entity, this.mapping.GetTableName(table));
Expression where = null;
if (generatedIds.Count > 0)
{
where = generatedIds.Select((m, i) =>
this.GetMemberExpression(tex, entity, m).Equal(map[m])
).Aggregate((x, y) => x.And(y));
}
else
{
where = this.GetIdentityCheck(tex, entity, instance);
}
TableAlias selectAlias = new TableAlias();
var columns = new List<ColumnDeclaration>();
var variables = new List<VariableDeclaration>();
foreach (var mi in members)
{
ColumnExpression col = (ColumnExpression)this.GetMemberExpression(tex, entity, mi);
columns.Add(new ColumnDeclaration(this.mapping.GetColumnName(entity, mi), col, col.QueryType));
ColumnExpression vcol = new ColumnExpression(col.Type, col.QueryType, selectAlias, col.Name);
variables.Add(new VariableDeclaration(mi.Name, col.QueryType, vcol));
map.Add(mi, new VariableExpression(mi.Name, col.Type, col.QueryType));
}
var genMembersCommand = new DeclarationCommand(variables, new SelectExpression(selectAlias, columns, tex, where));
if (genIdCommand != null)
{
return new BlockCommand(genIdCommand, genMembersCommand);
}
return genMembersCommand;
}
开发者ID:rdrawsky,项目名称:iqtoolkit,代码行数:57,代码来源:AdvancedMapping.cs
示例18: GetColumns
private void GetColumns(MappingEntity entity, Dictionary<string, TableAlias> aliases, List<ColumnDeclaration> columns)
{
foreach (MemberInfo mi in this.mapping.GetMappedMembers(entity))
{
if (!this.mapping.IsAssociationRelationship(entity, mi))
{
if (this.mapping.IsNestedEntity(entity, mi))
{
this.GetColumns(this.mapping.GetRelatedEntity(entity, mi), aliases, columns);
}
else if (this.mapping.IsColumn(entity, mi))
{
string name = this.mapping.GetColumnName(entity, mi);
string aliasName = this.mapping.GetAlias(entity, mi);
TableAlias alias;
aliases.TryGetValue(aliasName, out alias);
var colType = this.GetColumnType(entity, mi);
ColumnExpression ce = new ColumnExpression(TypeHelper.GetMemberType(mi), colType, alias, name);
ColumnDeclaration cd = new ColumnDeclaration(name, ce, colType);
columns.Add(cd);
}
}
}
}
开发者ID:rdrawsky,项目名称:iqtoolkit,代码行数:24,代码来源:AdvancedMapping.cs
示例19: GetQueryExpression
public override ProjectionExpression GetQueryExpression(MappingEntity entity)
{
var tables = this.mapping.GetTables(entity);
if (tables.Count <= 1)
{
return base.GetQueryExpression(entity);
}
var aliases = new Dictionary<string, TableAlias>();
MappingTable rootTable = tables.Single(ta => !this.mapping.IsExtensionTable(ta));
var tex = new TableExpression(new TableAlias(), entity, this.mapping.GetTableName(rootTable));
aliases.Add(this.mapping.GetAlias(rootTable), tex.Alias);
Expression source = tex;
foreach (MappingTable table in tables.Where(t => this.mapping.IsExtensionTable(t)))
{
TableAlias joinedTableAlias = new TableAlias();
string extensionAlias = this.mapping.GetAlias(table);
aliases.Add(extensionAlias, joinedTableAlias);
List<string> keyColumns = this.mapping.GetExtensionKeyColumnNames(table).ToList();
List<MemberInfo> relatedMembers = this.mapping.GetExtensionRelatedMembers(table).ToList();
string relatedAlias = this.mapping.GetExtensionRelatedAlias(table);
TableAlias relatedTableAlias;
aliases.TryGetValue(relatedAlias, out relatedTableAlias);
TableExpression joinedTex = new TableExpression(joinedTableAlias, entity, this.mapping.GetTableName(table));
Expression cond = null;
for (int i = 0, n = keyColumns.Count; i < n; i++)
{
var memberType = TypeHelper.GetMemberType(relatedMembers[i]);
var colType = this.GetColumnType(entity, relatedMembers[i]);
var relatedColumn = new ColumnExpression(memberType, colType, relatedTableAlias, this.mapping.GetColumnName(entity, relatedMembers[i]));
var joinedColumn = new ColumnExpression(memberType, colType, joinedTableAlias, keyColumns[i]);
var eq = joinedColumn.Equal(relatedColumn);
cond = (cond != null) ? cond.And(eq) : eq;
}
source = new JoinExpression(JoinType.SingletonLeftOuter, source, joinedTex, cond);
}
var columns = new List<ColumnDeclaration>();
this.GetColumns(entity, aliases, columns);
SelectExpression root = new SelectExpression(new TableAlias(), columns, source, null);
var existingAliases = aliases.Values.ToArray();
Expression projector = this.GetEntityExpression(root, entity);
var selectAlias = new TableAlias();
var pc = ColumnProjector.ProjectColumns(this.Translator.Linguist.Language, projector, null, selectAlias, root.Alias);
var proj = new ProjectionExpression(
new SelectExpression(selectAlias, pc.Columns, root, null),
pc.Projector
);
return (ProjectionExpression)this.Translator.Police.ApplyPolicy(proj, entity.ElementType);
}
开发者ID:rdrawsky,项目名称:iqtoolkit,代码行数:58,代码来源:AdvancedMapping.cs
示例20: VisitColumn
protected override Expression VisitColumn(ColumnExpression column)
{
Expression result;
if (CurrentScope.TryGetValue(column, out result))
return result ?? column;
else
{
CurrentScope[column] = null;
return column;
}
}
开发者ID:nuub666,项目名称:framework,代码行数:11,代码来源:QueryRebinder.cs
注:本文中的ColumnExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论