当前位置: 首页>>代码示例>>C#>>正文


C# SqlNode.Equals方法代码示例

本文整理汇总了C#中SqlNode.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# SqlNode.Equals方法的具体用法?C# SqlNode.Equals怎么用?C# SqlNode.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlNode的用法示例。


在下文中一共展示了SqlNode.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AreEqual

        internal static bool AreEqual(SqlNode node1, SqlNode node2) {
            if (node1 == node2)
                return true;
            if (node1 == null || node2 == null)
                return false;           

            if (node1.NodeType == SqlNodeType.SimpleCase)
                node1 = UnwrapTrivialCaseExpression((SqlSimpleCase)node1);

            if (node2.NodeType == SqlNodeType.SimpleCase)
                node2 = UnwrapTrivialCaseExpression((SqlSimpleCase)node2);

            if (node1.NodeType != node2.NodeType) {
                // allow expression sets to compare against single expressions
                if (node1.NodeType == SqlNodeType.ExprSet) {
                    SqlExprSet eset = (SqlExprSet)node1;
                    for (int i = 0, n = eset.Expressions.Count; i < n; i++) {
                        if (AreEqual(eset.Expressions[i], node2))
                            return true;
                    }
                }
                else if (node2.NodeType == SqlNodeType.ExprSet) {
                    SqlExprSet eset = (SqlExprSet)node2;
                    for (int i = 0, n = eset.Expressions.Count; i < n; i++) {
                        if (AreEqual(node1, eset.Expressions[i]))
                            return true;
                    }
                }
                return false;
            }
            if (node1.Equals(node2))
                return true;

            switch (node1.NodeType) {
                case SqlNodeType.Not:
                case SqlNodeType.Not2V:
                case SqlNodeType.Negate:
                case SqlNodeType.BitNot:
                case SqlNodeType.IsNull:
                case SqlNodeType.IsNotNull:
                case SqlNodeType.Count:
                case SqlNodeType.Max:
                case SqlNodeType.Min:
                case SqlNodeType.Sum:
                case SqlNodeType.Avg:
                case SqlNodeType.Stddev:
                case SqlNodeType.ValueOf:
                case SqlNodeType.OuterJoinedValue:
                case SqlNodeType.ClrLength:
                    return AreEqual(((SqlUnary)node1).Operand, ((SqlUnary)node2).Operand);
                case SqlNodeType.Add:
                case SqlNodeType.Sub:
                case SqlNodeType.Mul:
                case SqlNodeType.Div:
                case SqlNodeType.Mod:
                case SqlNodeType.BitAnd:
                case SqlNodeType.BitOr:
                case SqlNodeType.BitXor:
                case SqlNodeType.And:
                case SqlNodeType.Or:
                case SqlNodeType.GE:
                case SqlNodeType.GT:
                case SqlNodeType.LE:
                case SqlNodeType.LT:
                case SqlNodeType.EQ:
                case SqlNodeType.NE:
                case SqlNodeType.EQ2V:
                case SqlNodeType.NE2V:
                case SqlNodeType.Concat:
                    SqlBinary firstNode = (SqlBinary)node1;
                    SqlBinary secondNode = (SqlBinary)node2;
                    return AreEqual(firstNode.Left, secondNode.Left)
                        && AreEqual(firstNode.Right, secondNode.Right);
                case SqlNodeType.Convert:
                case SqlNodeType.Treat: {
                        SqlUnary sun1 = (SqlUnary)node1;
                        SqlUnary sun2 = (SqlUnary)node2;
                        return sun1.ClrType == sun2.ClrType && sun1.SqlType == sun2.SqlType && AreEqual(sun1.Operand, sun2.Operand);
                    }
                case SqlNodeType.Between: {
                        SqlBetween b1 = (SqlBetween)node1;
                        SqlBetween b2 = (SqlBetween)node1;
                        return AreEqual(b1.Expression, b2.Expression) &&
                               AreEqual(b1.Start, b2.Start) &&
                               AreEqual(b1.End, b2.End);
                    }
                case SqlNodeType.Parameter:
                    return node1 == node2;
                case SqlNodeType.Alias:
                    return AreEqual(((SqlAlias)node1).Node, ((SqlAlias)node2).Node);
                case SqlNodeType.AliasRef:
                    return AreEqual(((SqlAliasRef)node1).Alias, ((SqlAliasRef)node2).Alias);
                case SqlNodeType.Column:
                    SqlColumn col1 = (SqlColumn)node1;
                    SqlColumn col2 = (SqlColumn)node2;
                    return col1 == col2 || (col1.Expression != null && col2.Expression != null && AreEqual(col1.Expression, col2.Expression));
                case SqlNodeType.Table:
                    return ((SqlTable)node1).MetaTable == ((SqlTable)node2).MetaTable;
                case SqlNodeType.Member:
                    return (((SqlMember)node1).Member == ((SqlMember)node2).Member) &&
//.........这里部分代码省略.........
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:SqlComparer.cs


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