Home > Mobile >  EF Core ToString() Method Causing Exception
EF Core ToString() Method Causing Exception

Time:06-24

So basically my code is breaking over below line

var saleOrderIds= saleOList.Select(saleOList => saleOList.SaleOrderId.ToString()).ToList();

At the above code following exception is occuring

System.InvalidOperationException comparisonType: CurrentCultureIgnoreCase))' could not be translated. Additional information: Translation of the 'string.Equals' overload with a 'StringComparison' parameter is not supported.

The Same Line Was Working Fine In .Net Framework

How to resolve the issue , is there any alternate way to achieve the result in EfCore,.Net6 ?

CodePudding user response:

var saleOrderIds= saleOList.Select(saleOList => saleOList.SaleOrderId).ToList().Select(x => x.ToString());

That said, I wonder if this is an x-y problem. Normally, converting integer primary keys into strings is a bad idea. Why are you doing that?

  • Related