The method 'AsEnumerable' is not supported when called on an instance of type 'String'

Last Reply one year ago By Mudassar

Posted one year ago

An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code

Additional information: The method 'AsEnumerable' is not supported when called on an instance of type 'String'.

  static IEnumerable<CultureInfo> GetCultureInfosByCurrencySymbol(string currencycode)
        {
            if (currencycode == null)
            {
                throw new ArgumentNullException("currencycode");
            }

            return CultureInfo.GetCultures(CultureTypes.SpecificCultures)
                .Where(x => new RegionInfo(x.LCID).ISOCurrencySymbol == currencycode);
        }
       

var data = db.Sales.Select(c => new SalesViewModel
           {
               SID = c.SID,
               Person = c.Person,
               Period = c.Period,
               Amount = c.Amount,
               Currencycode = c.Currencycode
          .AsEnumerable()
             .Select(x => new { S = GetCultureInfosByCurrencySymbol(c.Currency)}).ToString()
            }).ToList();
Posted one year ago

This means

 GetCultureInfosByCurrencySymbol(c.Currency)

is not a Collection while you trying to use like Collection