/// <summary>
/// Adds actual 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 SelectTableFields(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 (EntityFieldExtensions.IsTableField(field))
{
if (excludeFields == null ||
!excludeFields.Contains(field))
{
query.Select(field);
}
}
}
return(query);
}