Illegal mix of collations for operation ' IN ', While using LINQ Lambda with contains clause

Viewed 73

I am having Linq query that fetch city names as keyValue pair, Refer below code

 public List<KeyValuePair<string, int>> GetCityKeyValuesByNames(List<string> cityNames)
        {
           
                var cityList = _cityRepo
                    .GetConditionalQuery(x => cityNames.Contains(x.Name))
                    .Select(x => new { Key = x.Name, Value = x.Id })
                    .AsEnumerable()
                    .Select(x => new KeyValuePair<string, int>(x.Key, x.Value))
                    .ToList();

                return cityList;                
        }

However we getting Eception MySql.Data.MySqlClient.MySqlException: Illegal mix of collations for operation ' IN ', How I can control the collation in EF Linq query?

0 Answers
Related