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

Last Reply on Nov 09, 2017 04:59 AM By Mudassar

Posted on Nov 08, 2017 10:41 PM

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();
You are viewing reply posted by: Mudassar on Nov 09, 2017 04:59 AM.
Posted on Nov 09, 2017 04:59 AM

This means

 GetCultureInfosByCurrencySymbol(c.Currency)

is not a Collection while you trying to use like Collection