• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TableAlias类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TableAlias的典型用法代码示例。如果您正苦于以下问题:C# TableAlias类的具体用法?C# TableAlias怎么用?C# TableAlias使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TableAlias类属于命名空间,在下文中一共展示了TableAlias类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VisitSelect

 protected override Expression VisitSelect(SelectExpression select)
 {
     TableAlias newAlias = new TableAlias();
     this.map[select.Alias] = newAlias;
     select = (SelectExpression)base.VisitSelect(select);
     return new SelectExpression(newAlias, select.Columns, select.From, select.Where, select.OrderBy, select.GroupBy, select.IsDistinct, select.Skip, select.Take, select.IsReverse);
 }
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:7,代码来源:QueryDuplicator.cs


示例2: AddAlias

 protected void AddAlias(TableAlias alias)
 {
     if (!this.aliasMap.ContainsKey(alias))
     {
         this.aliasMap.Add(alias, this.aliasMap.Count);
     }
 }
开发者ID:bisand,项目名称:NetCouch,代码行数:7,代码来源:DbExpressionWriter.cs


示例3: Visit

 public override TableAlias Visit(TableAlias item)
 {
     if (item == null)
         return null;
     TableAlias result;
     if (!aliasesMapping.TryGetValue(item, out result))
         if (!aliasesMapping.TryGetValue(TableAlias.All, out result))
             return item;
     return result;
 }
开发者ID:npenin,项目名称:uss,代码行数:10,代码来源:LazyAliasResolver.cs


示例4: AddRedundantSelect

        public static SelectExpression AddRedundantSelect(this SelectExpression sel, QueryLanguage language, TableAlias newAlias)
        {
            var newColumns =
                from d in sel.Columns
                let qt = (d.Expression is ColumnExpression) ? ((ColumnExpression)d.Expression).QueryType : language.TypeSystem.GetColumnType(d.Expression.Type)
                select new ColumnDeclaration(d.Name, new ColumnExpression(d.Expression.Type, qt, newAlias, d.Name), qt);

            var newFrom = new SelectExpression(newAlias, sel.Columns, sel.From, sel.Where, sel.OrderBy, sel.GroupBy, sel.IsDistinct, sel.Skip, sel.Take, sel.IsReverse);
            return new SelectExpression(sel.Alias, newColumns, newFrom, null, null, null, false, null, null, false);
        }
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:10,代码来源:DbExpressionExtensions.cs


示例5: MarkColumnAsUsed

 private void MarkColumnAsUsed(TableAlias alias, string name)
 {
     HashSet<string> columns;
     if (!this.allColumnsUsed.TryGetValue(alias, out columns))
     {
         columns = new HashSet<string>();
         this.allColumnsUsed.Add(alias, columns);
     }
     columns.Add(name);
 }
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:10,代码来源:UnusedColumnRemover.cs


示例6: 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


示例7: IsColumnUsed

 private bool IsColumnUsed(TableAlias alias, string name)
 {
     HashSet<string> columnsUsed;
     if (this.allColumnsUsed.TryGetValue(alias, out columnsUsed))
     {
         if (columnsUsed != null)
         {
             return columnsUsed.Contains(name);
         }
     }
     return false;
 }
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:12,代码来源:UnusedColumnRemover.cs


示例8: ColumnProjector

 private ColumnProjector(Expression expression, IEnumerable<ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable<TableAlias> existingAliases)
 {
     this.newAlias = newAlias;
     this.existingAliases = new HashSet<TableAlias>(existingAliases, TableAlias.Comparer);
     this.map = new Dictionary<ColumnExpression, ColumnExpression>();
     if (existingColumns != null)
     {
         this.columns = new List<ColumnDeclaration>(existingColumns);
         this.columnNames = new HashSet<string>(existingColumns.Select(c => c.Name), StringComparer.Ordinal);
     }
     else
     {
         this.columns = new List<ColumnDeclaration>();
         this.columnNames = new HashSet<string>(StringComparer.Ordinal);
     }
     this.candidates = Nominator.Nominate(expression);
 }
开发者ID:netcasewqs,项目名称:elinq,代码行数:17,代码来源:ColumnProjector.cs


示例9: ColumnProjector

 private ColumnProjector(Func<Expression, bool> fnCanBeColumn, Expression expression, IEnumerable<ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable<TableAlias> existingAliases)
 {
     this.newAlias = newAlias;
     this.existingAliases = new HashSet<TableAlias>(existingAliases);
     this.map = new Dictionary<ColumnExpression, ColumnExpression>();
     if (existingColumns != null)
     {
         this.columns = new List<ColumnDeclaration>(existingColumns);
         this.columnNames = new HashSet<string>(existingColumns.Select(c => c.Name));
     }
     else
     {
         this.columns = new List<ColumnDeclaration>();
         this.columnNames = new HashSet<string>();
     }
     this.candidates = Nominator.Nominate(fnCanBeColumn, expression);
 }
开发者ID:maravillas,项目名称:linq-to-delicious,代码行数:17,代码来源:ColumnProjector.cs


示例10: 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


示例11: MakeSubquery

        private Expression MakeSubquery(Expression expression)
        {
            var newAlias = new TableAlias();
            var aliases = TableAliasGatherer.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.SqlType);
                    decls.Add(decl);
                    var newCol = new ColumnExpression(col.Type, col.SqlType, newAlias, name);
                    this.map.Add(col, newCol);
                }
            }

            return new SelectExpression(newAlias, decls, expression, null);
        }
开发者ID:netcasewqs,项目名称:elinq,代码行数:20,代码来源:CrossJoinIsolator.cs


示例12: VisitTable

 protected override Expression VisitTable(TableExpression table)
 {
     TableAlias newAlias = new TableAlias();
     this.map[table.Alias] = newAlias;
     return new TableExpression(newAlias, table.Entity, table.Name);
 }
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:6,代码来源:QueryDuplicator.cs


示例13: GetInsertExpression

        public override Expression GetInsertExpression(MappingEntity entity, Expression instance, LambdaExpression selector)
        {
            var tables = this.mapping.GetTables(entity);
            if (tables.Count < 2)
            {
                return base.GetInsertExpression(entity, instance, selector);
            }

            var commands = new List<Expression>();

            var map = this.GetDependentGeneratedColumns(entity);
            var vexMap = new Dictionary<MemberInfo, Expression>();

            foreach (var table in this.GetDependencyOrderedTables(entity))
            {
                var tableAlias = new TableAlias();
                var tex = new TableExpression(tableAlias, entity, this.mapping.GetTableName(table));
                var assignments = this.GetColumnAssignments(tex, instance, entity,
                    (e, m) => this.mapping.GetAlias(e, m) == this.mapping.GetAlias(table) && !this.mapping.IsGenerated(e, m),
                    vexMap
                    );
                var totalAssignments = assignments.Concat(
                    this.GetRelatedColumnAssignments(tex, entity, table, vexMap)
                    );
                commands.Add(new InsertCommand(tex, totalAssignments));

                List<MemberInfo> members;
                if (map.TryGetValue(this.mapping.GetAlias(table), out members))
                {
                    var d = this.GetDependentGeneratedVariableDeclaration(entity, table, members, instance, vexMap);
                    commands.Add(d);
                }
            }

            if (selector != null)
            {
                commands.Add(this.GetInsertResult(entity, instance, selector, vexMap));
            }

            return new BlockCommand(commands);
        }
开发者ID:rdrawsky,项目名称:iqtoolkit,代码行数:41,代码来源:AdvancedMapping.cs


示例14: 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


示例15: GetInsertExpression

        public override Expression GetInsertExpression(MappingEntity entity, Expression instance, LambdaExpression selector)
        {
            var tableAlias = new TableAlias();
            var table = new TableExpression(tableAlias, entity, this.mapping.GetTableName(entity));
            var assignments = this.GetColumnAssignments(table, instance, entity, (e, m) => !this.mapping.IsGenerated(e, m));

            if (selector != null)
            {
                return new BlockCommand(
                    new InsertCommand(table, assignments),
                    this.GetInsertResult(entity, instance, selector, null)
                    );
            }

            return new InsertCommand(table, assignments);
        }
开发者ID:jeswin,项目名称:AgileFx,代码行数:16,代码来源:BasicMapping.cs


示例16: AddAlias

 protected void AddAlias(TableAlias alias)
 {
     string name;
     if (!this.aliases.TryGetValue(alias, out name))
     {
         name = "t" + this.aliases.Count;
         this.aliases.Add(alias, name);
     }
 }
开发者ID:firestrand,项目名称:IQToolkit,代码行数:9,代码来源:SqlFormatter.cs


示例17: GetInsertResult

        protected virtual Expression GetInsertResult(MappingEntity entity, Expression instance, LambdaExpression selector, Dictionary<MemberInfo, Expression> map)
        {
            var tableAlias = new TableAlias();
            var tex = new TableExpression(tableAlias, entity, this.mapping.GetTableName(entity));
            var aggregator = Aggregator.GetAggregator(selector.Body.Type, typeof(IEnumerable<>).MakeGenericType(selector.Body.Type));

            Expression where;
            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)
            {
                if (map == null || !generatedIds.Any(m => map.ContainsKey(m)))
                {
                    var localMap = new Dictionary<MemberInfo, Expression>();
                    genIdCommand = this.GetGeneratedIdCommand(entity, generatedIds.ToList(), localMap);
                    map = localMap;
                }

                // is this just a retrieval of one generated id member?
                var mex = selector.Body as MemberExpression;
                if (mex != null && this.mapping.IsPrimaryKey(entity, mex.Member) && this.mapping.IsGenerated(entity, mex.Member))
                {
                    if (genIdCommand != null)
                    {
                        // just use the select from the genIdCommand
                        return new ProjectionExpression(
                            genIdCommand.Source,
                            new ColumnExpression(mex.Type, genIdCommand.Variables[0].QueryType, genIdCommand.Source.Alias, genIdCommand.Source.Columns[0].Name),
                            aggregator
                            );
                    }
                    else
                    {
                        TableAlias alias = new TableAlias();
                        var colType = this.GetColumnType(entity, mex.Member);
                        return new ProjectionExpression(
                            new SelectExpression(alias, new[] { new ColumnDeclaration("", map[mex.Member], colType) }, null, null),
                            new ColumnExpression(TypeHelper.GetMemberType(mex.Member), colType, alias, ""),
                            aggregator
                            );
                    }
                }

                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);
            }

            Expression typeProjector = this.GetEntityExpression(tex, entity);
            Expression selection = DbExpressionReplacer.Replace(selector.Body, selector.Parameters[0], typeProjector);
            TableAlias newAlias = new TableAlias();
            var pc = ColumnProjector.ProjectColumns(this.translator.Linguist.Language, selection, null, newAlias, tableAlias);
            var pe = new ProjectionExpression(
                new SelectExpression(newAlias, pc.Columns, tex, where),
                pc.Projector,
                aggregator
                );

            if (genIdCommand != null)
            {
                return new BlockCommand(genIdCommand, pe);
            }
            return pe;
        }
开发者ID:jeswin,项目名称:AgileFx,代码行数:68,代码来源:BasicMapping.cs


示例18: CompareAlias

 protected virtual bool CompareAlias(TableAlias a, TableAlias b)
 {
     if (this.aliasScope != null)
     {
         TableAlias mapped;
         if (this.aliasScope.TryGetValue(a, out mapped))
             return mapped == b;
     }
     return a == b;
 }
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:10,代码来源:DbExpressionComparer.cs


示例19: GetUpdateResult

 protected virtual Expression GetUpdateResult(MappingEntity entity, Expression instance, LambdaExpression selector)
 {
     var tq = this.GetQueryExpression(entity);
     Expression where = this.GetIdentityCheck(tq.Select, entity, instance);
     Expression selection = DbExpressionReplacer.Replace(selector.Body, selector.Parameters[0], tq.Projector);
     TableAlias newAlias = new TableAlias();
     var pc = ColumnProjector.ProjectColumns(this.translator.Linguist.Language, selection, null, newAlias, tq.Select.Alias);
     return new ProjectionExpression(
         new SelectExpression(newAlias, pc.Columns, tq.Select, where),
         pc.Projector,
         Aggregator.GetAggregator(selector.Body.Type, typeof(IEnumerable<>).MakeGenericType(selector.Body.Type))
         );
 }
开发者ID:jeswin,项目名称:AgileFx,代码行数:13,代码来源:BasicMapping.cs


示例20: GetUpdateExpression

        public override Expression GetUpdateExpression(MappingEntity entity, Expression instance, LambdaExpression updateCheck, LambdaExpression selector, Expression @else)
        {
            var tableAlias = new TableAlias();
            var table = new TableExpression(tableAlias, entity, this.mapping.GetTableName(entity));

            var where = this.GetIdentityCheck(table, entity, instance);
            if (updateCheck != null)
            {
                Expression typeProjector = this.GetEntityExpression(table, entity);
                Expression pred = DbExpressionReplacer.Replace(updateCheck.Body, updateCheck.Parameters[0], typeProjector);
                where = where.And(pred);
            }

            var assignments = this.GetColumnAssignments(table, instance, entity, (e, m) => this.mapping.IsUpdatable(e, m));

            Expression update = new UpdateCommand(table, where, assignments);

            if (selector != null)
            {
                return new BlockCommand(
                    update,
                    new IFCommand(
                        this.translator.Linguist.Language.GetRowsAffectedExpression(update).GreaterThan(Expression.Constant(0)),
                        this.GetUpdateResult(entity, instance, selector),
                        @else
                        )
                    );
            }
            else if (@else != null)
            {
                return new BlockCommand(
                    update,
                    new IFCommand(
                        this.translator.Linguist.Language.GetRowsAffectedExpression(update).LessThanOrEqual(Expression.Constant(0)),
                        @else,
                        null
                        )
                    );
            }
            else
            {
                return update;
            }
        }
开发者ID:jeswin,项目名称:AgileFx,代码行数:44,代码来源:BasicMapping.cs



注:本文中的TableAlias类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TableBatchOperation类代码示例发布时间:2022-05-24
下一篇:
C# Table类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap