From() публичный Метод

Adds a table to the FROM statement, with given short name.
This overload requires that alias has a table name.
public From ( IAlias alias ) : SqlQuery
alias IAlias Alias that contains table name and short name.
Результат SqlQuery
Пример #1
0
        /// <summary>
        /// Adds a table to the FROM statement with "T0" alias and sets it as target for future field selections.
        /// </summary>
        /// <param name="row">Row object.</param>
        /// <returns>The query itself.</returns>
        public static SqlQuery From(this SqlQuery query, IEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("row");
            }

            var row = entity as Row;

            if (row != null)
            {
                query.From(row.GetFields());
            }
            else
            {
                var alias = entity as IAlias;
                if (alias != null && (alias.Name == "t0" || alias.Name == "T0") && alias.Table == entity.Table)
                {
                    query.From(alias);
                }
                else
                {
                    query.From(entity.Table, Alias.T0);
                }
            }

            return(query.Into(entity));
        }
Пример #2
0
        /// <summary>
        /// Adds a table to the FROM statement with "T0" alias and sets it as target for future field selections.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        /// The query itself.
        /// </returns>
        /// <exception cref="ArgumentNullException">row</exception>
        public static SqlQuery From(this SqlQuery query, IEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("row");
            }

            if (entity as IRow != null)
            {
                var fields = (entity as IRow).Fields;
                query.From(fields);
                if (!query.IsDialectOverridden)
                {
                    query.Dialect(fields.Dialect);
                }
            }
            else
            {
                if (entity as IAlias != null && ((entity as IAlias).Name == "t0" || (entity as IAlias).Name == "T0") && (entity as IAlias).Table == entity.Table)
                {
                    query.From(entity as IAlias);
                }
                else
                {
                    query.From(entity.Table, Alias.T0);
                }
            }

            return(query.Into(entity));
        }
        /// <summary>
        /// Adds a table to the FROM statement with "T0" alias and sets it as target for future field selections.
        /// </summary>
        /// <param name="row">Row object.</param>
        /// <returns>The query itself.</returns>
        public static SqlQuery From(this SqlQuery query, IEntity row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            query.From(row.Table, Alias.T0).Into(row);

            return(query);
        }
Пример #4
0
        /// <summary>
        /// Adds a table to the FROM statement with "T0" alias and sets it as target for future field selections.
        /// </summary>
        /// <param name="row">Row object.</param>
        /// <returns>The query itself.</returns>
        public static SqlQuery From(this SqlQuery query, IEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("row");
            }

            var row = entity as Row;

            if (row != null)
            {
                var fields = row.GetFields();
                query.From(fields);
                if (!query.IsDialectOverridden && !string.IsNullOrEmpty(fields.connectionKey))
                {
                    var cs = SqlConnections.TryGetConnectionString(fields.connectionKey);
                    if (cs != null)
                    {
                        query.Dialect(cs.Dialect);
                    }
                }
            }
            else
            {
                var alias = entity as IAlias;
                if (alias != null && (alias.Name == "t0" || alias.Name == "T0") && alias.Table == entity.Table)
                {
                    query.From(alias);
                }
                else
                {
                    query.From(entity.Table, string.Empty, Alias.T0);
                }
            }

            return(query.Into(entity));
        }