示例#1
0
            public override void Visit(DbScanExpression expression)
            {
                Check.NotNull(expression, "expression");

                // we know we won't hit this code unless there is no function defined for this
                // ModificationOperation, so if this EntitySet is using a DefiningQuery, instead
                // of a table, that is an error
                if (expression.Target.GetMetadataPropertyValue <string>("DefiningQuery") != null)
                {
                    string missingCudElement;
                    if (_commandTree is DbDeleteCommandTree)
                    {
                        missingCudElement = "DeleteFunction";
                    }
                    else if (_commandTree is DbInsertCommandTree)
                    {
                        missingCudElement = "InsertFunction";
                    }
                    else
                    {
                        Debug.Assert(_commandTree is DbUpdateCommandTree);
                        missingCudElement = "UpdateFunction";
                    }
                    throw new UpdateException(
                              Strings.Update_SqlEntitySetWithoutDmlFunctions(
                                  expression.Target.Name, missingCudElement, "ModificationFunctionMapping"));
                }

                _commandText.Append(SqlGenerator.GetTargetTSql(expression.Target));
            }
            public override void Visit(DbScanExpression scanExpression)
            {
                string         str         = SqlGenerator.GetTargetTSql(scanExpression.Target) + " AS " + (this._currentTableAlias = "t" + (object)this._aliasCount++);
                EntityTypeBase elementType = scanExpression.Target.ElementType;

                if (this._from.Length == 0)
                {
                    this._baseTable = (EntityType)elementType;
                    this._from.Append("FROM ");
                    this._from.Append(str);
                }
                else
                {
                    this._from.AppendLine();
                    this._from.Append("JOIN ");
                    this._from.Append(str);
                    this._from.Append(" ON ");
                    for (int index = 0; index < elementType.KeyMembers.Count; ++index)
                    {
                        if (index > 0)
                        {
                            this._from.Append(" AND ");
                        }
                        this._from.Append(this._currentTableAlias + ".");
                        this._from.Append(SqlGenerator.QuoteIdentifier(elementType.KeyMembers[index].Name));
                        this._from.Append(" = t0.");
                        this._from.Append(SqlGenerator.QuoteIdentifier(this._baseTable.KeyMembers[index].Name));
                    }
                }
            }
 public override void Visit(DbScanExpression expression)
 {
     Check.NotNull <DbScanExpression>(expression, nameof(expression));
     if (expression.Target.GetMetadataPropertyValue <string>("DefiningQuery") != null)
     {
         string str = !(this._commandTree is DbDeleteCommandTree) ? (!(this._commandTree is DbInsertCommandTree) ? "UpdateFunction" : "InsertFunction") : "DeleteFunction";
         throw new UpdateException(Strings.Update_SqlEntitySetWithoutDmlFunctions((object)expression.Target.Name, (object)str, (object)"ModificationFunctionMapping"));
     }
     this._commandText.Append(SqlGenerator.GetTargetTSql(expression.Target));
 }
            public override void Visit(DbScanExpression scanExpression)
            {
                DebugCheck.NotNull(scanExpression);

                var tableSql
                    = SqlGenerator.GetTargetTSql(scanExpression.Target)
                      + " AS "
                      + (_currentTableAlias = "t" + _aliasCount++);

                var table = scanExpression.Target.ElementType;

                if (_from.Length == 0)
                {
                    _baseTable = (EntityType)table;

                    _from.Append("FROM ");
                    _from.Append(tableSql);
                }
                else
                {
                    _from.AppendLine();
                    _from.Append("JOIN ");
                    _from.Append(tableSql);
                    _from.Append(" ON ");

                    for (var i = 0; i < table.KeyMembers.Count; i++)
                    {
                        if (i > 0)
                        {
                            _from.Append(" AND ");
                        }

                        _from.Append(_currentTableAlias + ".");
                        _from.Append(SqlGenerator.QuoteIdentifier(table.KeyMembers[i].Name));
                        _from.Append(" = t0.");
                        _from.Append(SqlGenerator.QuoteIdentifier(_baseTable.KeyMembers[i].Name));
                    }
                }
            }