Sarvesh Patil
Sarvesh Patil

Reputation: 95

EF Core ToString() Method Causing Exception

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 ?

Upvotes: 0

Views: 298

Answers (1)

John Zabroski
John Zabroski

Reputation: 2349

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?

Upvotes: 3

Related Questions