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


C# EntityCollection.AddRange方法代码示例

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


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

示例1: Confirm

        public WeeklySummaryCollection Confirm(int confirmUserID, int entityID)
        {
            User _confirmUser = (new UserAccessClient(EndpointName.UserAccess)).QueryuserID(confirmUserID)[0];

            WeeklySummaryCollection _confirm = new WeeklySummaryCollection();

            Entity _entity = EntityService.Instance.LoadEntity(entityID)[0];

            if ((_entity.SumType != SumType.Transaction) && (_entity.SumType != SumType.Subtotal))
            {
                return _confirm;
            }

            _entity.SubEntities = ((_entity.SumType == SumType.Transaction) ? SetSubtotal(_entity.SubEntities, new WeeklySummaryCollection()) : SetLastLevel(_entity.SubEntities, new WeeklySummaryCollection()));

            ConfirmTransfer(new EntityCollection(new Entity[] { _entity }), _confirm);

            if (_confirm.Count <= 0)
            {
                return _confirm;
            }

            foreach (WeeklySummary _weeklySummary in _confirm)
            {
                _weeklySummary.Status = WeeklySummaryStatus.Confirm;
                _weeklySummary.ConfirmUser = _confirmUser;
            }

            using (WeeklySummaryAccessClient _weeklySummaryAccessClient = new WeeklySummaryAccessClient(EndpointName.WeeklySummaryAccess))
            {
                _weeklySummaryAccessClient.Update2(_confirm.ToArray());
            }

            //<EntityID, RecordID>
            Dictionary<int, int> _pairs = new Dictionary<int, int>();

            foreach (WeeklySummary _weeklySummary in _confirm)
            {
                int _recordID = -1;

                using (RecordAccessClient _recordAccessClient = new RecordAccessClient(EndpointName.RecordAccess))
                {
                    _pairs[_weeklySummary.Entity.EntityID] = (_recordID = _recordAccessClient.QueryRecordID(_weeklySummary.Entity.EntityID, PeriodService.Instance.GetCurrentPeriod()[0].ID));
                }

                if (_recordID > 0)
                {
                    if (_pairs.Values.Count(RecordID => (RecordID == _recordID)) == 1)
                    {
                        using (RecordAccessClient _recordAccessClient = new RecordAccessClient(EndpointName.RecordAccess))
                        {
                            _recordAccessClient.ChangeStatus(_recordID, RecordStatus.Confirm);
                        }
                    }
                }
            }

            foreach (KeyValuePair<int, int> _pair in _pairs)
            {
                if (_pair.Value > 0)
                {
                    continue;
                }

                Entity _subtotal = null;

                if (_entity.SumType == SumType.Transaction)
                {
                    if ((_subtotal = _entity.SubEntities.FirstOrDefault(Entity => (_pair.Key == Entity.EntityID))) == null)
                    {
                        continue;
                    }
                }
                else if (_pair.Key == _entity.EntityID)
                {
                    _subtotal = _entity;
                }
                else
                {
                    continue;
                }

                EntityCollection _entityCollection = new EntityCollection() { _subtotal };

                _entityCollection.AddRange(_subtotal.SubEntities);

                decimal[] _baseTransfer = new decimal[_entityCollection.Count];

                for (int i = 1; i < _entityCollection.Count; i++)
                {
                    _baseTransfer[i] = _confirm.FirstOrDefault(WeeklySummary => (WeeklySummary.Entity.EntityID == _entityCollection[i].EntityID)).BaseTransfer;
                }

                Transfer _transfer = CalculateService.Instance.Transfer(confirmUserID, _entityCollection, _baseTransfer).Item1;

                DataEntryService.Instance.InsertTransfer(_transfer.RecordNotInDB, _transfer);
            }

            return _confirm;
        }
开发者ID:WiseLinProject,项目名称:Projects,代码行数:100,代码来源:TallyService.svc.cs


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