Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
List<OrderItem> store = new List<OrderItem>();
            IQueryable<OrderItem> in_store = datas.Where(c => c.OrderTypeId == 1).Select(c => c.OrderItems).SelectMany(a => a.Where(c => !c.isdeleted), (a, b) => b);
foreach (OrderItem it in in_store)
            {
       var add = store.SingleOrDefault(c => c.ContragentId == it.ContragentId && c.GoodTypeId == it.GoodTypeId && c.GoodCost == it.GoodCost && c.Order.StoreId == it.Order.StoreId);
                if (add != null) add.GoodCount += it.GoodCount;
                else store.Add(it);
            }

how to rewrite this code in one linq query?
the store variable in result must be iqueryable
all operations does not need to implement ienumerable only iqueryable
Posted
Comments
Sampath Lokuge 4-Feb-14 8:23am    
Why you need to do that ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900