linq to sql ,将var 类型转为 IList 类型

 public void SOHSelecting(int startRowIndex, int maximumRows, string sortExpression, string location)
        {
            int totalCount = 0;
            IList<Logistics.LogisticsBinReference> getSOHList = new List<LogisticsBinReference>();

            var list = View.SohLists.Where(c => c.SubInventory == location).GroupBy(x => x.BinLocation).Select(x => new  {
                BinLocation = x.First().BinLocation,
                SOH = x.Sum(y => y.SOH)
            }).ToList();

            IList<LogisticsBinReference> list2 = new List<LogisticsBinReference>();
            foreach (var item in list)
            {
                LogisticsBinReference l = new LogisticsBinReference();
                l.BinLocation = item.BinLocation;
                l.SOH = item.SOH;
                list2.Add(l);
            }

            getSOHList = list2.AsQueryable().SortingAndPaging(sortExpression, startRowIndex, maximumRows, out totalCount).ToList();

            View.SOHTotalCount = totalCount;
            View.BindSOHObjectContainerDataSource(getSOHList);
        }
原文地址:https://www.cnblogs.com/liuwj/p/5010026.html