示例#1
0
 public static DataTable Pivot(this IDataReader reader, PivotDef pivotDef, Comparison<PivotedColumn> pivotedColumnComparison)
 {
     if (reader == null) throw new ArgumentNullException("reader");
     if (pivotDef == null) throw new ArgumentNullException("pivotDef");
     if (pivotedColumnComparison == null) throw new ArgumentNullException("pivotedColumnComparison");
     if (pivotDef.UnpivotedColumnNames == null) throw new ArgumentException("UnpivotedColumns must not be null");
     if (pivotDef.PivotTransforms == null) throw new ArgumentException("PivotColumns must not be null");
     if (pivotDef.PivotTransforms.Any(x => x == null)) throw new ArgumentException("All PivotColums mut be not null");
     var builder = new SimplePivotBuilder(pivotDef, reader, pivotedColumnComparison);
     return builder.Build();
 }
示例#2
0
        public DataTable Pivot(Comparison <PivotedColumn> pivotedColumnComparison, params PivotTransform[] pivotTransforms)
        {
            var cmd = new CommandExecutor(this.DataService, true)
            {
                GetCommandFunc = GetSelectCommand,
                CommandTimeout = this.CommandTimeout
            };

            var properties = this.EntityType.GetEntityMetadata().Properties;

            IEnumerable <string> unpivotedPropertyNames = this.Sort
                                                          .Where(x => !pivotTransforms.Any(p => p.PivotColumnName == x.FieldName || p.ValueColumnName == x.FieldName))
                                                          .Select(x => x.FieldName);

            using (var reader = cmd.ExecuteReader())
            {
                PivotDef pivotDef = new PivotDef
                {
                    UnpivotedColumnNames = unpivotedPropertyNames.ToArray(),
                    PivotTransforms      = pivotTransforms
                };
                return(reader.Pivot(pivotDef, pivotedColumnComparison));
            }
        }
示例#3
0
 public SimplePivotBuilder(PivotDef pivotDef, IDataReader reader, Comparison<PivotedColumn> pivotedColumnComparison)
 {
     this.PivotedColumnComparison = pivotedColumnComparison;
     this.PivotDef = pivotDef;
     this.Reader = reader;
 }
示例#4
0
 public static DataTable Pivot(this IDataReader reader, PivotDef pivotDef)
 {
     return Pivot(reader, pivotDef, DefaultPivotedColumnComparison);
 }
示例#5
0
        public DataTable Pivot(Comparison<PivotedColumn> pivotedColumnComparison, params PivotTransform[] pivotTransforms)
        {
            var cmd = new CommandExecutor(this.DataService, true)
            {
                GetCommandFunc = GetSelectCommand,
                CommandTimeout = this.CommandTimeout
            };

            var properties = this.EntityType.GetEntityMetadata().Properties;

            IEnumerable<string> unpivotedPropertyNames = this.Sort
                                .Where(x => !pivotTransforms.Any(p => p.PivotColumnName == x.FieldName || p.ValueColumnName == x.FieldName))
                                .Select(x => x.FieldName);

            using (var reader = cmd.ExecuteReader())
            {
                PivotDef pivotDef = new PivotDef
                {
                    UnpivotedColumnNames = unpivotedPropertyNames.ToArray(),
                    PivotTransforms = pivotTransforms
                };
                return reader.Pivot(pivotDef, pivotedColumnComparison);
            }
        }