Click here to Skip to main content
15,904,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I cretae a list like below am getting error system.linq.Iqueyable<anonymoustype1#>doesnot contains a definition for 'ToList' and the best extension method overload 'system.linq.parellelIEnumerable.ToList<<Tsource> has some invalid arguements.Can anyone help me to findout the mistake?
C#
List<ren> renewedorderlist = 
  (from ordernum in salesContext.SL_OrderIdMapper
     where ordernum.OrderNumber==placeOrderModel.OrderInfo.OrderID
   from orderDetail in salesContext.SL_OrderDetails
     where ordernum.OrderId == orderDetail.OrderId
   from renProducts in salesContext.products
     where renProducts.pid == orderDetail.ProductID
   from licenseDetails in salesContext.SL_LicenseDetails
     where licenseDetails.OrderDetailId == orderDetail.OrderDetailId
   from licenses in salesContext.SL_License
     where licenses.LicenseId == licenseDetails.LicenseId
   from oldProducts in salesContext.products
     where oldProducts.pid == licenses.ProductID
   select new
   {
     OrderId = ordernum.OrderNumber,
     OldProductName = oldProducts.productdesc,
     NewProductName = renProducts.productdesc,
     Quantity = orderDetail.Quantity,
     LicenseID = licenses.LicenseId
   }).ToList<ren>();
Posted
Updated 30-Apr-14 2:13am
v2

1 solution

You try to convert a collection of anonymous types to a List with elements of the type ren. Change select new { into select new ren() {
C#
List<ren> renewedorderlist = 
  (from ordernum in salesContext.SL_OrderIdMapper
     where ordernum.OrderNumber==placeOrderModel.OrderInfo.OrderID
   from orderDetail in salesContext.SL_OrderDetails
     where ordernum.OrderId == orderDetail.OrderId
   from renProducts in salesContext.products
     where renProducts.pid == orderDetail.ProductID
   from licenseDetails in salesContext.SL_LicenseDetails
     where licenseDetails.OrderDetailId == orderDetail.OrderDetailId
   from licenses in salesContext.SL_License
     where licenses.LicenseId == licenseDetails.LicenseId
   from oldProducts in salesContext.products
     where oldProducts.pid == licenses.ProductID
   select new ren() // <-- here
   {
     OrderId = ordernum.OrderNumber,
     OldProductName = oldProducts.productdesc,
     NewProductName = renProducts.productdesc,
     Quantity = orderDetail.Quantity,
     LicenseID = licenses.LicenseId
   }).ToList<ren>();
 
Share this answer
 
Comments
Maciej Los 30-Apr-14 8:27am    
5ed!
Thomas Daniels 30-Apr-14 8:31am    
Thank you!
NithyaGopu 30-Apr-14 8:28am    
Fine.It is working...thank you so much
Thomas Daniels 30-Apr-14 8:31am    
You're welcome!

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