0
var assignresult = (from i in _Objcontext.DistributorProductMappings 
                    where i.ProductId == items.ProductID && i.DistributorId == items.DId && i.UpdatedDate == items.UpdatedDate 
                    select (int.Parse(i.Purchases) + int.Parse(i.StockTakeback)).ToString()
                   ).FirstOrDefault() ?? "0"; 

this statement not working convertions fails

1 Answers1

2

Your linq expression will be translated to expression that Sql understands, in this case int.Parse will not have equivalent conversion.

To fix this issue, use Convert.ToInt32() instead of int.Parse

Hari Prasad
  • 16,716
  • 4
  • 21
  • 35
  • 1
    Why do you think `Convert.ToInt32` is supported? The truth is that there is **no** any conversion method supported from string to other data type. – Ivan Stoev Jul 12 '16 at 11:53