Ejemplo n.º 1
0
        private List <SqlExpression> GetIdentityExpressions(MetaType type, SqlExpression expr)
        {
            List <MetaDataMember> list = this.GetIdentityMembers(type).ToList <MetaDataMember>();
            var list2 = new List <SqlExpression>(list.Count);

            foreach (MetaDataMember member in list)
            {
                list2.Add(this.sql.Member((SqlExpression)SqlDuplicator.Copy(expr), member));
            }
            return(list2);
        }
Ejemplo n.º 2
0
 internal override SqlExpression VisitMultiset(SqlSubSelect sms)
 {
     if (((((this.options & SqlMultiplexer.Options.EnableBigJoin) != SqlMultiplexer.Options.None) && !this.hasBigJoin) &&
          (this.canJoin && this.isTopLevel)) && (((this.outerSelect != null) && !MultisetChecker.HasMultiset(sms.Select.Selection)) &&
                                                 BigJoinChecker.CanBigJoin(sms.Select)))
     {
         sms.Select = this.VisitSelect(sms.Select);
         SqlAlias right = new SqlAlias(sms.Select);
         SqlJoin  join  = new SqlJoin(SqlJoinType.OuterApply, this.outerSelect.From, right, null, sms.SourceExpression);
         this.outerSelect.From         = join;
         this.outerSelect.OrderingType = SqlOrderingType.Always;
         SqlExpression expression = (SqlExpression)SqlDuplicator.Copy(sms.Select.Selection);
         SqlSelect     node       = (SqlSelect)SqlDuplicator.Copy(sms.Select);
         SqlAlias      from       = new SqlAlias(node);
         SqlSelect     select     = new SqlSelect(this.sql.Unary(SqlNodeType.Count, null, sms.SourceExpression), from, sms.SourceExpression);
         select.OrderingType = SqlOrderingType.Never;
         SqlExpression       count   = this.sql.SubSelect(SqlNodeType.ScalarSubSelect, select);
         SqlJoinedCollection joineds = new SqlJoinedCollection(sms.ClrType, sms.SqlType, expression, count, sms.SourceExpression);
         this.hasBigJoin = true;
         return(joineds);
     }
     return(QueryExtractor.Extract(sms, this.parentParameters, sqlIdentity));
 }
Ejemplo n.º 3
0
        private SqlExpression TranslateEqualsOp(SqlNodeType op, SqlExpression left, SqlExpression right, bool allowExpand)
        {
            switch (op)
            {
            case SqlNodeType.EQ:
            case SqlNodeType.NE:
                return(this.sql.Binary(op, left, right));

            case SqlNodeType.EQ2V:
            {
                if ((SqlExpressionNullability.CanBeNull(left) != false) && (SqlExpressionNullability.CanBeNull(right) != false))
                {
                    SqlNodeType type = allowExpand ? SqlNodeType.EQ2V : SqlNodeType.EQ;
                    return(this.sql.Binary(SqlNodeType.Or, this.sql.Binary(SqlNodeType.And, this.sql.Unary(SqlNodeType.IsNull, (SqlExpression)SqlDuplicator.Copy(left)), this.sql.Unary(SqlNodeType.IsNull, (SqlExpression)SqlDuplicator.Copy(right))),
                                           this.sql.Binary(SqlNodeType.And, this.sql.Binary(SqlNodeType.And, this.sql.Unary(SqlNodeType.IsNotNull, (SqlExpression)SqlDuplicator.Copy(left)), this.sql.Unary(SqlNodeType.IsNotNull, (SqlExpression)SqlDuplicator.Copy(right))), this.sql.Binary(type, left, right))));
                }
                SqlNodeType nodeType = allowExpand ? SqlNodeType.EQ2V : SqlNodeType.EQ;
                return(this.sql.Binary(nodeType, left, right));
            }

            case SqlNodeType.NE2V:
            {
                if ((SqlExpressionNullability.CanBeNull(left) == false) || (SqlExpressionNullability.CanBeNull(right) == false))
                {
                    SqlNodeType type4 = allowExpand ? SqlNodeType.NE2V : SqlNodeType.NE;
                    return(this.sql.Binary(type4, left, right));
                }
                SqlNodeType type3 = allowExpand ? SqlNodeType.EQ2V : SqlNodeType.EQ;
                return(this.sql.Unary(SqlNodeType.Not, this.sql.Binary(SqlNodeType.Or, this.sql.Binary(SqlNodeType.And, this.sql.Unary(SqlNodeType.IsNull, (SqlExpression)SqlDuplicator.Copy(left)), this.sql.Unary(SqlNodeType.IsNull, (SqlExpression)SqlDuplicator.Copy(right))), this.sql.Binary(SqlNodeType.And, this.sql.Binary(SqlNodeType.And, this.sql.Unary(SqlNodeType.IsNotNull, (SqlExpression)SqlDuplicator.Copy(left)), this.sql.Unary(SqlNodeType.IsNotNull, (SqlExpression)SqlDuplicator.Copy(right))), this.sql.Binary(type3, left, right)))));
            }
            }
            throw Error.UnexpectedNode(op);
        }