예제 #1
0
            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);
                }
            }
예제 #2
0
 private void VerifyTargetColumn(Column target, string paramName)
 {
     target.VerifyNotNull(paramName);
     if (target.ParentModel != Model || _targetColumns.Contains(target))
     {
         throw new ArgumentException(DiagnosticMessages.DbQueryBuilder_VerifyTargetColumn, paramName);
     }
 }
예제 #3
0
 private static void VerifyOrderBy(Column column, string paramName)
 {
     column.VerifyNotNull(paramName);
     if (column.ScalarSourceModels.Count != 1)
     {
         throw new ArgumentException(DiagnosticMessages.DataRow_OrderByColumnMustBeSingleSourceModel, paramName);
     }
 }
예제 #4
0
 private void VerifyTarget(Column targetColumn, string paramName)
 {
     targetColumn.VerifyNotNull(paramName);
     if (targetColumn.ParentModel != _targetModel)
     {
         throw new ArgumentException(DiagnosticMessages.ColumnMapper_InvalidTarget(targetColumn), paramName);
     }
 }
예제 #5
0
파일: Column.cs 프로젝트: aTiKhan/RDO.Net
 IColumns IColumns.Add(Column value)
 {
     value.VerifyNotNull(nameof(value));
     if (value == this)
     {
         return(this);
     }
     return(Columns.New(this, value));
 }
예제 #6
0
파일: Column.cs 프로젝트: aTiKhan/RDO.Net
 IColumns IColumns.Remove(Column value)
 {
     value.VerifyNotNull(nameof(value));
     if (value == this)
     {
         return(Columns.Empty);
     }
     else
     {
         return(this);
     }
 }
예제 #7
0
        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);
                }
            }
        }
예제 #8
0
        /// <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);
        }
예제 #9
0
            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);
            }
예제 #10
0
 /// <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>());
 }
예제 #11
0
 /// <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));
 }
예제 #12
0
 public bool Contains(Column value)
 {
     value.VerifyNotNull(nameof(value));
     return(_hashSet.Contains(value));
 }
예제 #13
0
 /// <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>());
 }
예제 #14
0
 /// <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>());
 }
예제 #15
0
 /// <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>());
 }
예제 #16
0
 /// <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));
 }
예제 #17
0
 public bool Contains(Column value)
 {
     value.VerifyNotNull(nameof(value));
     return(false);
 }
예제 #18
0
 /// <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>());
 }
예제 #19
0
 public IColumns Remove(Column value)
 {
     value.VerifyNotNull(nameof(value));
     return(this);
 }
예제 #20
0
 public IColumns Add(Column value)
 {
     value.VerifyNotNull(nameof(value));
     return(value);
 }
예제 #21
0
 /// <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>());
 }
예제 #22
0
파일: Case.cs 프로젝트: xydoublez/RDO.Net
 /// <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));
 }