Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 ?

>Solution :

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?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading