当前位置: 首页>>代码示例>>C#>>正文


C# Row.CreateKey方法代码示例

本文整理汇总了C#中Row.CreateKey方法的典型用法代码示例。如果您正苦于以下问题:C# Row.CreateKey方法的具体用法?C# Row.CreateKey怎么用?C# Row.CreateKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Row的用法示例。


在下文中一共展示了Row.CreateKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_generate_ObjectArrayKeys_without_specifying_column_names

        public void Can_generate_ObjectArrayKeys_without_specifying_column_names()
        {
            Row row = new Row();

            row["a"] = 1;

            Assert.DoesNotThrow(() => row.CreateKey());
        }
开发者ID:hoffmanc,项目名称:rhino-etl,代码行数:8,代码来源:RowTest.cs

示例2: Can_generate_ObjectArrayKeys_without_specifying_column_names

        public void Can_generate_ObjectArrayKeys_without_specifying_column_names()
        {
            Row row = new Row();

            row["a"] = 1;

            Exception ex = Record.Exception(() => row.CreateKey());

            Assert.Null(ex);
        }
开发者ID:regisbsb,项目名称:rhino-etl,代码行数:10,代码来源:RowTest.cs

示例3: Accumulate

        protected override void Accumulate(Row row, Row aggregate) {
            //init
            if (!aggregate.ContainsKey(_firstKey)) {
                foreach (var alias in _keysToGroupBy) {
                    aggregate[alias] = row[alias];
                }

                foreach (var field in _fieldsToAccumulate) {
                    if (_needZero.ContainsKey(field.Aggregate)) {
                        aggregate[field.Alias] = 0;
                    } else {
                        if (field.Aggregate.Equals("minlength")) {
                            aggregate[field.Alias] = row[field.Alias].ToString().Length;
                        } else {
                            aggregate[field.Alias] = row[field.Alias];
                        }
                    }
                }
            }

            //accumulate
            foreach (var field in _fieldsToAccumulate) {
                int len;
                switch (field.Aggregate) {
                    case "count":
                        if (field.Distinct) {
                            var key = row.CreateKey(_keysToGroupBy);
                            var value = row[field.Name];
                            if (!_distinct[field.Alias].ContainsKey(key)) {
                                _distinct[field.Alias].Add(key, new Dictionary<object, byte>());
                            }
                            if (!_distinct[field.Alias][key].ContainsKey(value)) {
                                _distinct[field.Alias][key].Add(value, 0);
                                aggregate[field.Alias] = (int)aggregate[field.Alias] + 1;
                            }
                            break;
                        }
                        aggregate[field.Alias] = (int)aggregate[field.Alias] + 1;
                        break;
                    case "sum":
                        aggregate[field.Alias] = (dynamic)aggregate[field.Alias] + (dynamic)row[field.Alias];
                        break;
                    case "max":
                        switch (field.SimpleType) {
                            case "byte[]":
                                aggregate[field.Alias] = Max((byte[])aggregate[field.Alias], (byte[])row[field.Alias]);
                                break;
                            default:
                                var comparable = aggregate[field.Alias] as IComparable;
                                if (comparable != null) {
                                    if (comparable.CompareTo(row[field.Alias]) < 0) {
                                        aggregate[field.Alias] = row[field.Alias];
                                    }
                                }
                                break;
                        }
                        break;
                    case "min":
                        switch (field.SimpleType) {
                            case "byte[]":
                                aggregate[field.Alias] = Min((byte[])aggregate[field.Alias], (byte[])row[field.Alias]);
                                break;
                            default:
                                var comparable = aggregate[field.Alias] as IComparable;
                                if (comparable != null) {
                                    if (comparable.CompareTo(row[field.Alias]) > 0) {
                                        aggregate[field.Alias] = row[field.Alias];
                                    }
                                }
                                break;
                        }
                        break;

                    case "maxlength":
                        len = row[field.Alias].ToString().Length;
                        if (len > (dynamic)aggregate[field.Alias]) {
                            aggregate[field.Alias] = len;
                        }
                        break;

                    case "minlength":
                        len = row[field.Alias].ToString().Length;
                        if (len < (dynamic)aggregate[field.Alias]) {
                            aggregate[field.Alias] = len;
                        }
                        break;

                    case "first":
                        if (aggregate[field.Alias] == null) {
                            aggregate[field.Alias] = row[field.Alias];
                        }
                        break;

                    case "last":
                        aggregate[field.Alias] = row[field.Alias];
                        break;

                    case "join":
                        Keep(field.Alias, row);
                        break;
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:Transformalize,代码行数:101,代码来源:EntityAggregation.cs

示例4: FinishAggregation

 protected override void FinishAggregation(Row aggregate) {
     //final accumulate
     var group = aggregate.CreateKey(_keysToGroupBy);
     foreach (var field in _fieldsToAccumulate) {
         switch (field.Aggregate) {
             case "join":
                 aggregate[field.Alias] = string.Join(field.Delimiter, field.Distinct ? _lists[field.Alias][@group].Distinct() : _lists[field.Alias][@group]);
                 break;
             case "concat":
                 aggregate[field.Alias] = string.Concat(field.Distinct ? _lists[field.Alias][@group].Distinct() : _lists[field.Alias][@group]);
                 break;
             case "array":
                 aggregate[field.Alias] = (field.Distinct ? _lists[field.Alias][@group].Distinct() : _lists[field.Alias][@group]).ToArray();
                 break;
         }
     }
 }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:17,代码来源:EntityAggregation.cs

示例5: Keep

 private void Keep(string alias, Row row) {
     var key = row.CreateKey(_keysToGroupBy);
     if (_lists[alias].ContainsKey(key)) {
         _lists[alias][key].Add(row[alias]);
     } else {
         _lists[alias][key] = new List<object> { row[alias] };
     }
 }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:8,代码来源:EntityAggregation.cs


注:本文中的Row.CreateKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。