locked
.ToList - 'IEnumerable<dynamic>' does not contain a definition for 'ToList' RRS feed

  • Question

  • User379720387 posted

    holdIps is a IEnumberable<dynamic> holding a series of IP addresses

    holdIps.ToList() gives an exception "'IEnumerable<dynamic>' does not contain a definition for 'ToList' and no accessible extension method 'ToList' accepting a first argument of type 'IEnumerable<dynamic>'"

    var holdIps = db.Query("SELECT DISTINCT regIp FROM ProfileHOLD");
    
    if (holdIps.ToList().Contains(trueIP)) { isHoldIp = true; }

    I have a using System.Linq;

    Monday, November 25, 2019 5:11 PM

Answers

  • User475983607 posted

    The raw query syntax does not look correct.  What version of Entity Framework are you using?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 25, 2019 6:52 PM

All replies

  • User475983607 posted

    The raw query syntax does not look correct.  What version of Entity Framework are you using?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 25, 2019 6:52 PM
  • User379720387 posted

    It is not EF.

    Just a WebMatrix WebPages IEnumerable.

    Monday, November 25, 2019 9:23 PM
  • User475983607 posted

    Perhaps check if the query returned any results but the error indicates you are missing a LINQ extension reference..

    var holdIps = db.Query("SELECT DISTINCT regIp FROM ProfileHOLD");
    isHoldIp = holdIps.Any(m => m == trueIP);

    Monday, November 25, 2019 10:00 PM
  • User-719153870 posted

    Hi wavemaster,

    System.Linq can be .net framework version affected. I suggest you could check the target framework of your current project maybe it's too old, if is then update to the latest version available.

    Or are you using the Microsoft Webmatrix which is not supported instead of VS? If so, you should update your develop environment then, try Visual Studio.

    Best Regard,

    Yang Shen

    Tuesday, November 26, 2019 6:46 AM
  • User379720387 posted

    It appears that a Web Pages IEnumerable cannot be used with .Contains

    Changing my query over to Linq.

    Yes, I am using VS, just mentioned WebMatrix in conjunction with Web Pages to make it clear what I have. Web Pages by itself does have very little explanatory value.

    Tuesday, November 26, 2019 2:12 PM