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


C# IQueryable.ElementAt方法代码示例

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


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

示例1: LocateHighSwingPoints

        /// <summary>
        /// Method to calculate high swing points from list of stock data.
        /// </summary>
        /// <param name="stockPriceData">List of stock data in which high swing points has to be located.</param>
        /// <returns>List of stock data that are high swing points.</returns>
        private IQueryable<StockPriceData> LocateHighSwingPoints(IQueryable<StockPriceData> stockPriceData)
        {
            var waitTimeCounter = 1;
            var potentialHighSwingPointCounter = 0;
            var highSwingPoints = new List<StockPriceData>();

            // Iterate through each stock data starting the 2nd element.
            for (var loop = 1; loop < stockPriceData.Count(); loop++)
            {
                // If the current data is new potential high swing point.
                if (stockPriceData.ElementAt(loop).HighPrice > stockPriceData.ElementAt(potentialHighSwingPointCounter).HighPrice)
                {
                    // Reset waitTimeCounter.
                    waitTimeCounter = 1;

                    // Set potentialHighSwingPointCounter to current data index.
                    potentialHighSwingPointCounter = loop;
                }
                else
                {
                    // Increase the wait time counter.
                    waitTimeCounter++;

                    // Check if the potential swing point data has matured in terms of wait time.
                    if (waitTimeCounter == WAIT_TIME)
                    {
                        // Add the potential swing point to the actual swing point list.
                        highSwingPoints.Add(stockPriceData.ElementAt(potentialHighSwingPointCounter));

                        // Reset waitTimeCounter.
                        waitTimeCounter = 1;

                        // Set potentialLowSwingPointCounter to current data index.
                        potentialHighSwingPointCounter = loop;
                    }
                }
            }

            return highSwingPoints.AsQueryable();
        }
开发者ID:omprsingh,项目名称:CashCow,代码行数:45,代码来源:SwingPointLocatorService.cs

示例2: Init

        public void Init()
        {
            _accessSingle = new List<Tuple<ResourceType, object>>();
            _accessMany = new List<Tuple<ResourceType, IEnumerable>>();
            _created = new List<Tuple<ResourceType, object>>();
            _updated = new List<Tuple<ResourceType, object>>();
            _removed = new List<Tuple<ResourceType, object>>();

            _product1Set = new List<Product1>
                           	{
                           		new Product1() { Id = 1, Name = "Product1" },
                                new Product1() { Id = 2, Name = "Product2" },
                           	}.AsQueryable();
            _catalog1Set = new List<Catalog1>
                           	{
                           		new Catalog1() { Id = 1, Name = "Cat1"},
                                new Catalog1() { Id = 2, Name = "Cat2" }
                           	}.AsQueryable();

            _supplier1Set = new List<Supplier1>
                            {
                                new Supplier1() { Id = 1, Address = new Address1() { Street = "wilson ave", Zip = "vxxxx", Country = "canada"} },
                                new Supplier1() { Id = 2, Address = new Address1() { Street = "kingsway ave", Zip = "zxxxx", Country = "canada"} },
                            }.AsQueryable();

            _catalog1Set.ElementAt(0).Products = new List<Product1>(_product1Set);
            _catalog1Set.ElementAt(1).Products = new List<Product1>(_product1Set);
            _product1Set.ElementAt(0).Catalog = _catalog1Set.ElementAt(0);
            _product1Set.ElementAt(1).Catalog = _catalog1Set.ElementAt(1);

            _model = new StubModel(
                m =>
                {
                    m.EntitySet("catalogs", _catalog1Set);
                    m.EntitySet("products", _product1Set);
                    m.EntitySet("suppliers", _supplier1Set);
                });

            _body = new StringBuilder();
        }
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:40,代码来源:SegmentProcessorTestCase.cs


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