public IColumns Add(Column value) { value.VerifyNotNull(nameof(value)); if (Contains(value)) { return(this); } if (!IsSealed) { _hashSet.Add(value); return(this); } if (Count == 0) { return(value); } else { var result = new HashSetColumns(); foreach (var column in this) { result.Add(column); } result.Add(value); return(result); } }
private void VerifyTargetColumn(Column target, string paramName) { target.VerifyNotNull(paramName); if (target.ParentModel != Model || _targetColumns.Contains(target)) { throw new ArgumentException(DiagnosticMessages.DbQueryBuilder_VerifyTargetColumn, paramName); } }
private static void VerifyOrderBy(Column column, string paramName) { column.VerifyNotNull(paramName); if (column.ScalarSourceModels.Count != 1) { throw new ArgumentException(DiagnosticMessages.DataRow_OrderByColumnMustBeSingleSourceModel, paramName); } }
private void VerifyTarget(Column targetColumn, string paramName) { targetColumn.VerifyNotNull(paramName); if (targetColumn.ParentModel != _targetModel) { throw new ArgumentException(DiagnosticMessages.ColumnMapper_InvalidTarget(targetColumn), paramName); } }
IColumns IColumns.Add(Column value) { value.VerifyNotNull(nameof(value)); if (value == this) { return(this); } return(Columns.New(this, value)); }
IColumns IColumns.Remove(Column value) { value.VerifyNotNull(nameof(value)); if (value == this) { return(Columns.Empty); } else { return(this); } }
private void VerifySource(Column sourceColumn, string paramName) { sourceColumn.VerifyNotNull(paramName); var sourceModels = sourceColumn.ScalarSourceModels; foreach (var sourceModel in sourceModels) { if (sourceModel != _sourceModel && sourceModel != _targetModel) { throw new ArgumentException(DiagnosticMessages.ColumnMapper_InvalidSourceParentModelSet(sourceModel), paramName); } } }
/// <summary>Defines the computation expression for this column.</summary> /// <param name="computation">The computation expression.</param> /// <param name="isConcrete">Specifies whether this column stores concrete computed data values.</param> /// <param name="isDbComputed">Specifies wheter the computation valid on database.</param> public void ComputedAs(Column <T> computation, bool isConcrete = true, bool isDbComputed = true) { computation.VerifyNotNull(nameof(computation)); if (ParentModel == null) { throw new InvalidOperationException(DiagnosticMessages.Column_ComputedColumnMustBeMemberOfModel); } if (Expression != null) { throw new InvalidOperationException(DiagnosticMessages.Column_AlreadyComputed); } VerifyDesignMode(); SetComputation(computation, isConcrete, isDbComputed); }
public IColumns Remove(Column value) { value.VerifyNotNull(nameof(value)); if (!Contains(value)) { return(this); } if (Count == 1) { return(Empty); } if (Count == 2) { return(_hashSet.Single(x => x != value)); } if (!IsSealed) { _hashSet.Remove(value); return(this); } var result = new HashSetColumns(); foreach (var element in this) { if (element != value) { result.Add(element); } } return(result); }
/// <summary> /// Calculates the average value for a specified column. /// </summary> /// <param name="x">The specified column.</param> /// <returns>The result average value.</returns> public static _Double Average(this Column <Int32?> x) { x.VerifyNotNull(nameof(x)); return(new AverageInt32(x).MakeColumn <_Double>()); }
/// <summary> /// Maps between two columns unsafely. /// </summary> /// <param name="source">The source column.</param> /// <param name="target">The target column.</param> /// <returns>The mapping between these two columns.</returns> /// <remarks>You must ensure type safety of the columns, otherwise an exception may be thrown when using returned <see cref="ColumnMapping" />.</remarks> public static ColumnMapping UnsafeMap(Column source, Column target) { target.VerifyNotNull(nameof(target)); return(new ColumnMapping(source, target)); }
public bool Contains(Column value) { value.VerifyNotNull(nameof(value)); return(_hashSet.Contains(value)); }
/// <summary> /// Determines whether specified column is not null value. /// </summary> /// <param name="x">The column.</param> /// <returns>The <see cref="_Boolean"/> column which contains the result.</returns> public static _Boolean IsNotNull(this Column x) { x.VerifyNotNull(nameof(x)); return(new IsNotNullFunction(x).MakeColumn <_Boolean>()); }
/// <summary> /// Calculates total value for specified column. /// </summary> /// <param name="x">The specified column.</param> /// <returns>The column contains the total result.</returns> public static _Single Sum(this Column <Single?> x) { x.VerifyNotNull(nameof(x)); return(new SumSingle(x).MakeColumn <_Single>()); }
/// <summary> /// Calculates total value for specified column. /// </summary> /// <param name="x">The specified column.</param> /// <returns>The column contains the total result.</returns> public static _Int32 Sum(this Column <Int32?> x) { x.VerifyNotNull(nameof(x)); return(new SumInt32(x).MakeColumn <_Int32>()); }
/// <summary> /// Maps between two columns. /// </summary> /// <typeparam name="T">The data type of the column.</typeparam> /// <param name="source">The source column.</param> /// <param name="target">The target column.</param> /// <returns>The mapping between these two columns.</returns> public static ColumnMapping Map <T>(Column <T> source, Column <T> target) { source.VerifyNotNull(nameof(source)); target.VerifyNotNull(nameof(target)); return(new ColumnMapping(source, target)); }
public bool Contains(Column value) { value.VerifyNotNull(nameof(value)); return(false); }
/// <summary> /// Calculates the average value for a specified column. /// </summary> /// <param name="x">The specified column.</param> /// <returns>The result average value.</returns> public static _Single Average(this Column <Single?> x) { x.VerifyNotNull(nameof(x)); return(new AverageSingle(x).MakeColumn <_Single>()); }
public IColumns Remove(Column value) { value.VerifyNotNull(nameof(value)); return(this); }
public IColumns Add(Column value) { value.VerifyNotNull(nameof(value)); return(value); }
/// <summary> /// Calculates total value for specified column. /// </summary> /// <param name="x">The specified column.</param> /// <returns>The column contains the total result.</returns> public static _Decimal Sum(this Column <Decimal?> x) { x.VerifyNotNull(nameof(x)); return(new SumDecimal(x).MakeColumn <_Decimal>()); }
/// <summary> /// Constructs ON statement of CASE expression /// </summary> /// <typeparam name="T">Data type of the column.</typeparam> /// <param name="on">The column expression.</param> /// <returns>A <see cref="CaseOn{T}"/> struct for further expression construct.</returns> public static CaseOn <T> On <T>(Column <T> on) { on.VerifyNotNull(nameof(on)); return(new CaseOn <T>(on)); }