本文整理汇总了C#中ProjectionExpression类的典型用法代码示例。如果您正苦于以下问题:C# ProjectionExpression类的具体用法?C# ProjectionExpression怎么用?C# ProjectionExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectionExpression类属于命名空间,在下文中一共展示了ProjectionExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
using (Scope())
{
var oldOuterMostSelect = outerMostSelect;
outerMostSelect = proj.Select;
var oldHasProjectionInProjector = hasProjectionInProjector;
hasProjectionInProjector = false;
Expression projector = this.Visit(proj.Projector);
SelectExpression source = (SelectExpression)this.Visit(proj.Select);
hasProjectionInProjector = oldHasProjectionInProjector;
hasProjectionInProjector |= true;
outerMostSelect = oldOuterMostSelect;
if (source != proj.Select || projector != proj.Projector)
return new ProjectionExpression(source, projector, proj.UniqueFunction, proj.Type);
return proj;
}
}
开发者ID:nuub666,项目名称:framework,代码行数:26,代码来源:OrderByRewriter.cs
示例2: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
if (proj != root)
return AliasReplacer.Replace(base.VisitProjection(proj), aliasGenerator);
else
return (ProjectionExpression)base.VisitProjection(proj);
}
开发者ID:nuub666,项目名称:framework,代码行数:7,代码来源:AliasProjectionReplacer.cs
示例3: ProviderQueryExpression
public ProviderQueryExpression(
IEnumerable<ProviderPropertyExpression> providerProperties,
ProjectionExpression projection,
PredicateExpression predicate,
SortExpressionCollectionExpression sort)
: this(new ProviderPropertiesExpression(providerProperties), projection, predicate, sort)
{ }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:7,代码来源:ProviderQueryExpression.cs
示例4: 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
示例5: UpdateClientJoin
protected ClientJoinExpression UpdateClientJoin(ClientJoinExpression join, ProjectionExpression projection, IEnumerable<Expression> outerKey, IEnumerable<Expression> innerKey)
{
if (projection != join.Projection || outerKey != join.OuterKey || innerKey != join.InnerKey)
{
return new ClientJoinExpression(projection, outerKey, innerKey);
}
return join;
}
开发者ID:bisand,项目名称:NetCouch,代码行数:8,代码来源:DbExpressionVisitor.cs
示例6: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
// don't parameterize the projector or aggregator!
SelectExpression select = (SelectExpression)this.Visit(proj.Source);
if (select != proj.Source) {
return new ProjectionExpression(select, proj.Projector, proj.Aggregator);
}
return proj;
}
开发者ID:maravillas,项目名称:linq-to-delicious,代码行数:9,代码来源:Parameterizer.cs
示例7: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
Expression projector = this.Visit(proj.Projector);
if (projector != proj.Projector)
{
return new ProjectionExpression(proj.Source, projector, proj.Aggregator);
}
return proj;
}
开发者ID:maravillas,项目名称:linq-to-delicious,代码行数:9,代码来源:RelationshipIncluder.cs
示例8: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
SelectExpression save = this.currentSelect;
this.currentSelect = proj.Source;
try
{
if (!this.isTopLevel)
{
if (this.CanJoinOnClient(this.currentSelect))
{
// make a query that combines all the constraints from the outer queries into a single select
SelectExpression newOuterSelect = (SelectExpression)QueryDuplicator.Duplicate(save);
// remap any references to the outer select to the new alias;
SelectExpression newInnerSelect = (SelectExpression)ColumnMapper.Map(proj.Source, newOuterSelect.Alias, save.Alias);
// add outer-join test
ProjectionExpression newInnerProjection = new ProjectionExpression(newInnerSelect, proj.Projector).AddOuterJoinTest();
newInnerSelect = newInnerProjection.Source;
Expression newProjector = newInnerProjection.Projector;
TableAlias newAlias = new TableAlias();
var pc = ColumnProjector.ProjectColumns(this.language.CanBeColumn, newProjector, newOuterSelect.Columns, newAlias, newOuterSelect.Alias, newInnerSelect.Alias);
JoinExpression join = new JoinExpression(JoinType.OuterApply, newOuterSelect, newInnerSelect, null);
SelectExpression joinedSelect = new SelectExpression(newAlias, pc.Columns, join, null, null, null, proj.IsSingleton, null, null);
// apply client-join treatment recursively
this.currentSelect = joinedSelect;
newProjector = this.Visit(pc.Projector);
// compute keys (this only works if join condition was a single column comparison)
List<Expression> outerKeys = new List<Expression>();
List<Expression> innerKeys = new List<Expression>();
if (this.GetEquiJoinKeyExpressions(newInnerSelect.Where, newOuterSelect.Alias, outerKeys, innerKeys))
{
// outerKey needs to refer to the outer-scope's alias
var outerKey = outerKeys.Select(k => ColumnMapper.Map(k, save.Alias, newOuterSelect.Alias));
// innerKey needs to refer to the new alias for the select with the new join
var innerKey = innerKeys.Select(k => ColumnMapper.Map(k, joinedSelect.Alias, ((ColumnExpression)k).Alias));
ProjectionExpression newProjection = new ProjectionExpression(joinedSelect, newProjector, proj.Aggregator);
return new ClientJoinExpression(newProjection, outerKey, innerKey);
}
}
}
else
{
this.isTopLevel = false;
}
return base.VisitProjection(proj);
}
finally
{
this.currentSelect = save;
}
}
开发者ID:rodrigodom,项目名称:SubSonic-3.0,代码行数:55,代码来源:ClientJoinedProjectionRewriter.cs
示例9: Flatten
static internal ProjectionExpression Flatten(ProjectionExpression proj, AliasGenerator aliasGenerator)
{
var result = (ProjectionExpression)new ChildProjectionFlattener { aliasGenerator = aliasGenerator }.Visit(proj);
if (result == proj)
return result;
Expression columnCleaned = UnusedColumnRemover.Remove(result);
Expression subqueryCleaned = RedundantSubqueryRemover.Remove(columnCleaned);
return (ProjectionExpression)subqueryCleaned;
}
开发者ID:nuub666,项目名称:framework,代码行数:11,代码来源:ChildProjectionFlattener.cs
示例10: VisitProjection
protected override Expression VisitProjection(ProjectionExpression projection)
{
// visit mapping in reverse order
Expression projector = this.Visit(projection.Projector);
SelectExpression source = (SelectExpression)this.Visit(projection.Source);
if (projector != projection.Projector || source != projection.Source)
{
return new ProjectionExpression(source, projector, projection.Aggregator);
}
return projection;
}
开发者ID:6nop,项目名称:SubSonic-3.0,代码行数:11,代码来源:UnusedColumnRemover.cs
示例11: MergeProjectionExpressions
private static ProjectionExpression MergeProjectionExpressions(ProjectionExpression projection,
ProjectionExpression expression)
{
if (projection is AttributesProjectionExpression && expression is AttributesProjectionExpression)
{
List<PropertyNameExpression> expr = new List<PropertyNameExpression>();
expr.AddRange((projection as AttributesProjectionExpression).Attributes.Collection);
expr.AddRange((expression as AttributesProjectionExpression).Attributes.Collection);
return new AttributesProjectionExpression(expr);
}
throw GetMergeException(projection, expression);
}
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:12,代码来源:ExpressionMerger.cs
示例12: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
this.Visit(proj.Projector);
SelectExpression source = (SelectExpression)this.Visit(proj.Select);
Expression projector = this.Visit(proj.Projector);
if (source != proj.Select || projector != proj.Projector)
{
return new ProjectionExpression(source, projector, proj.UniqueFunction, proj.Type);
}
return proj;
}
开发者ID:nuub666,项目名称:framework,代码行数:13,代码来源:QueryRebinder.cs
示例13: VisitClientJoin
protected override Expression VisitClientJoin(ClientJoinExpression join)
{
// convert client join into a up-front lookup table builder & replace client-join in tree with lookup accessor
// 1) lookup = query.Select(e => new KVP(key: inner, value: e)).ToLookup(kvp => kvp.Key, kvp => kvp.Value)
Expression innerKey = MakeJoinKey(join.InnerKey);
Expression outerKey = MakeJoinKey(join.OuterKey);
ConstructorInfo kvpConstructor = typeof(KeyValuePair<,>).MakeGenericType(innerKey.Type, join.Projection.Projector.Type).GetConstructor(new System.Type[] { innerKey.Type, join.Projection.Projector.Type });
Expression constructKVPair = Expression.New(kvpConstructor, innerKey, join.Projection.Projector);
ProjectionExpression newProjection = new ProjectionExpression(join.Projection.Source, constructKVPair);
int iLookup = ++nLookup;
Expression execution = ExecuteProjection(newProjection, false);
ParameterExpression kvp = Expression.Parameter(constructKVPair.Type, "kvp");
// filter out nulls
if (join.Projection.Projector.NodeType == (ExpressionType)DbExpressionType.OuterJoined)
{
LambdaExpression pred = Expression.Lambda(
Expression.NotEqual(
Expression.PropertyOrField(kvp, "Value"),
Expression.Constant(null, join.Projection.Projector.Type)
),
kvp
);
execution = Expression.Call(typeof(Enumerable), "Where", new System.Type[] { kvp.Type }, execution, pred);
}
// make lookup
LambdaExpression keySelector = Expression.Lambda(Expression.PropertyOrField(kvp, "Key"), kvp);
LambdaExpression elementSelector = Expression.Lambda(Expression.PropertyOrField(kvp, "Value"), kvp);
Expression toLookup = Expression.Call(typeof(Enumerable), "ToLookup", new System.Type[] { kvp.Type, outerKey.Type, join.Projection.Projector.Type }, execution, keySelector, elementSelector);
// 2) agg(lookup[outer])
ParameterExpression lookup = Expression.Parameter(toLookup.Type, "lookup" + iLookup);
PropertyInfo property = lookup.Type.GetProperty("Item");
Expression access = Expression.Call(lookup, property.GetGetMethod(), Visit(outerKey));
if (join.Projection.Aggregator != null)
{
// apply aggregator
access = DbExpressionReplacer.Replace(join.Projection.Aggregator.Body, join.Projection.Aggregator.Parameters[0], access);
}
variables.Add(lookup);
initializers.Add(toLookup);
return access;
}
开发者ID:ScottWeinstein,项目名称:Linq2KdbQ,代码行数:50,代码来源:QExecutionBuilder.cs
示例14: VisitProjection
protected virtual Expression VisitProjection(ProjectionExpression projection)
{
this.AddAlias(projection.Source.Alias);
this.Write("Project(");
this.WriteLine(Indentation.Inner);
this.Write("@\"");
this.Visit(projection.Source);
this.Write("\",");
this.WriteLine(Indentation.Same);
this.Visit(projection.Projector);
this.Write(",");
this.WriteLine(Indentation.Same);
this.Visit(projection.Aggregator);
this.WriteLine(Indentation.Outer);
this.Write(")");
return projection;
}
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:17,代码来源:DbExpressionWriter.cs
示例15: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
if (isTopLevel)
{
isTopLevel = false;
currentSelect = proj.Source;
Expression projector = Visit(proj.Projector);
if (projector != proj.Projector || currentSelect != proj.Source)
{
return new ProjectionExpression(currentSelect, projector, proj.Aggregator);
}
return proj;
}
if (proj.IsSingleton && CanJoinOnServer(currentSelect))
{
TableAlias newAlias = new TableAlias();
currentSelect = currentSelect.AddRedundantSelect(newAlias);
// remap any references to the outer select to the new alias;
SelectExpression source =
(SelectExpression) ColumnMapper.Map(proj.Source, newAlias, currentSelect.Alias);
// add outer-join test
ProjectionExpression pex = new ProjectionExpression(source, proj.Projector).AddOuterJoinTest();
var pc = ColumnProjector.ProjectColumns(language.CanBeColumn, pex.Projector, currentSelect.Columns,
currentSelect.Alias, newAlias, proj.Source.Alias);
JoinExpression join = new JoinExpression(JoinType.OuterApply, currentSelect.From, pex.Source, null);
currentSelect = new SelectExpression(currentSelect.Alias, pc.Columns, join, null);
return Visit(pc.Projector);
}
var saveTop = isTopLevel;
var saveSelect = currentSelect;
isTopLevel = true;
currentSelect = null;
Expression result = base.VisitProjection(proj);
isTopLevel = saveTop;
currentSelect = saveSelect;
return result;
}
开发者ID:rodrigodom,项目名称:SubSonic-3.0,代码行数:44,代码来源:SingletonProjectionRewriter.cs
示例16: Translate
public override Expression Translate(Expression expression)
{
// fix up any order-by's
expression = OrderByRewriter.Rewrite(expression);
expression = base.Translate(expression);
// convert skip/take info into RowNumber pattern
if (isPaged(expression))
{
//we have some clean up here
//paging embeds a SELECT in the FROM expression
//this needs to be reset to the table name
//and Skip/Take need to be reset
var projection = expression as ProjectionExpression;
//pull the select
SelectExpression outer = projection.Source;
//take out the nested FROM
var inner = outer.From as SelectExpression;
//and stick it on the outer
outer.From = inner.From;
//the outer Skip is in place
//reset the Take since we need both on the Select
//for the formatter to work
outer.Take = inner.Take;
expression = new ProjectionExpression(outer, projection.Projector);
}
// fix up any order-by's we may have changed
expression = OrderByRewriter.Rewrite(expression);
return expression;
}
开发者ID:paprikon,项目名称:SubSonic-3.0,代码行数:39,代码来源:PostgreSqlLanguage.cs
示例17: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
// treat these like scalar subqueries
if ((proj.Projector is ColumnExpression) || this.forDebug)
{
this.Write("(");
this.WriteLine(Indentation.Inner);
this.Visit(proj.Select);
this.Write(")");
this.Indent(Indentation.Outer);
}
else
{
throw new NotSupportedException("Non-scalar projections cannot be translated to SQL.");
}
return proj;
}
开发者ID:firestrand,项目名称:IQToolkit,代码行数:17,代码来源:SqlFormatter.cs
示例18: 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
示例19: VisitProjection
protected override Expression VisitProjection(ProjectionExpression proj)
{
if (currentSource == null)
{
currentSource = WithoutOrder(proj.Select);
Expression projector = this.Visit(proj.Projector);
if (projector != proj.Projector)
proj = new ProjectionExpression(proj.Select, projector, proj.UniqueFunction, proj.Type);
currentSource = null;
return proj;
}
else
{
HashSet<ColumnExpression> columns = ExternalColumnGatherer.Gatherer(proj, currentSource.Alias);
if (columns.Count == 0)
{
Expression projector = Visit(proj.Projector);
ConstantExpression key = Expression.Constant(0);
Type kvpType = typeof(KeyValuePair<,>).MakeGenericType(key.Type, projector.Type);
ConstructorInfo ciKVP = kvpType.GetConstructor(new[] { key.Type, projector.Type });
Type projType = proj.UniqueFunction == null ? typeof(IEnumerable<>).MakeGenericType(kvpType) : kvpType;
var childProj = new ProjectionExpression(proj.Select,
Expression.New(ciKVP, key, projector), proj.UniqueFunction, projType);
return new ChildProjectionExpression(childProj,
Expression.Constant(0), inMList, proj.Type, new LookupToken());
}
else
{
SelectExpression external;
IEnumerable<ColumnExpression> externalColumns;
if (!IsKey(currentSource, columns))
{
Alias aliasDistinct = aliasGenerator.GetUniqueAlias(currentSource.Alias.Name + "D");
ColumnGenerator generatorDistinct = new ColumnGenerator();
List<ColumnDeclaration> columnDistinct = columns.Select(ce => generatorDistinct.MapColumn(ce)).ToList();
external = new SelectExpression(aliasDistinct, true, null, columnDistinct, currentSource, null, null, null, 0);
Dictionary<ColumnExpression, ColumnExpression> distinctReplacements = columnDistinct.ToDictionary(
cd => (ColumnExpression)cd.Expression,
cd => cd.GetReference(aliasDistinct));
proj = (ProjectionExpression)ColumnReplacer.Replace(proj, distinctReplacements);
externalColumns = distinctReplacements.Values.ToHashSet();
}
else
{
external = currentSource;
externalColumns = columns;
}
ColumnGenerator generatorSM = new ColumnGenerator();
List<ColumnDeclaration> columnsSMExternal = externalColumns.Select(ce => generatorSM.MapColumn(ce)).ToList();
List<ColumnDeclaration> columnsSMInternal = proj.Select.Columns.Select(cd => generatorSM.MapColumn(cd.GetReference(proj.Select.Alias))).ToList();
List<OrderExpression> innerOrders;
SelectExpression @internal = ExtractOrders(proj.Select, out innerOrders);
Alias aliasSM = aliasGenerator.GetUniqueAlias(@internal.Alias.Name + "SM");
SelectExpression selectMany = new SelectExpression(aliasSM, false, null, columnsSMExternal.Concat(columnsSMInternal),
new JoinExpression(JoinType.CrossApply,
external,
@internal, null), null, innerOrders, null, 0);
SelectExpression old = currentSource;
currentSource = WithoutOrder(selectMany);
var selectManyReplacements = selectMany.Columns.ToDictionary(
cd => (ColumnExpression)cd.Expression,
cd => cd.GetReference(aliasSM));
Expression projector = ColumnReplacer.Replace(proj.Projector, selectManyReplacements);
projector = Visit(projector);
currentSource = old;
Expression key = TupleReflection.TupleChainConstructor(columnsSMExternal.Select(cd => cd.GetReference(aliasSM).Nullify()));
Type kvpType = typeof(KeyValuePair<,>).MakeGenericType(key.Type, projector.Type);
ConstructorInfo ciKVP = kvpType.GetConstructor(new[] { key.Type, projector.Type });
Type projType = proj.UniqueFunction == null ? typeof(IEnumerable<>).MakeGenericType(kvpType) : kvpType;
var childProj = new ProjectionExpression(selectMany,
Expression.New(ciKVP, key, projector), proj.UniqueFunction, projType);
return new ChildProjectionExpression(childProj,
TupleReflection.TupleChainConstructor(columns.Select(a => a.Nullify())), inMList, proj.Type, new LookupToken());
}
}
//.........这里部分代码省略.........
开发者ID:nuub666,项目名称:framework,代码行数:101,代码来源:ChildProjectionFlattener.cs
示例20: VisitProjection
protected virtual Expression VisitProjection(ProjectionExpression proj)
{
SelectExpression source = (SelectExpression)this.Visit(proj.Source);
Expression projector = this.Visit(proj.Projector);
if (source != proj.Source || projector != proj.Projector)
{
return new ProjectionExpression(source, projector, proj.Aggregator);
}
return proj;
}
开发者ID:RyanDansie,项目名称:SubSonic-3.0,代码行数:10,代码来源:DbExpressionVisitor.cs
注:本文中的ProjectionExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论