Beispiel #1
0
        /// <summary>
        ///   Adds foreign / calculated table fields in a row to select list of a query.</summary>
        /// <param name="query">
        ///   Query to select fields into (required).</param>
        /// <param name="row">
        ///   Row with fields to be selected (required).</param>
        /// <param name="exclude">
        ///   Fields to be excluded (optional).</param>
        public static SqlQuery SelectForeignFields(this SqlQuery query, Row row, params Field[] exclude)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            HashSet <Field> excludeFields =
                (exclude != null && exclude.Length > 0) ? new HashSet <Field>(exclude) : null;

            var fields = row.GetFields();

            for (int i = 0; i < row.FieldCount; i++)
            {
                Field field = fields[i];
                if (!FieldExtensions.IsTableField(field) &&
                    (field.Flags & FieldFlags.ClientSide) != FieldFlags.ClientSide)
                {
                    if (excludeFields == null ||
                        !excludeFields.Contains(field))
                    {
                        query.Select(field);
                    }
                }
            }

            return(query);
        }
Beispiel #2
0
        /// <summary>
        ///   Adds foreign / calculated table fields in a row to select list of a query.</summary>
        /// <param name="query">
        ///   Query to select fields into (required).</param>
        /// <param name="row">
        ///   Row with fields to be selected (required).</param>
        /// <param name="exclude">
        ///   Fields to be excluded (optional).</param>
        public static SqlQuery SelectNonTableFields(this SqlQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            foreach (var field in ((Row)query.FirstIntoRow).GetFields())
            {
                if (!FieldExtensions.IsTableField(field) &&
                    (field.Flags & FieldFlags.ClientSide) != FieldFlags.ClientSide)
                {
                    query.Select(field);
                }
            }

            return(query);
        }