locked
does not contain a definition for 'Any' RRS feed

  • Question

  • User379720387 posted

    I am creating a method for a piece of code that I intend to re-use.  The code works as part of a cshtml file, but when I move it into a method get this error message:

    system.collections.generic.IEnumberable<dynamic> does not contain a definition for Any and no extension method Any

    using System;
    using System.Collections.Generic;
    using System.Web;
    using WebMatrix.Data;
    
    
    /// <summary>
    /// 
    /// </summary>
    public static class CalendarCleanUp
    {
        public static CalendarCleanUp(int providerid)
        {
        var db = Database.Open("StarterSite");
        int thisweekno = DateUtils.GetWeekNo(DateTime.Now);
        bool haschanged = false;
        bool isactive = true;
        var records = db.Query("SELECT calRId, weekNo, WeekSelectionId FROM calRecords cr JOIN TimeSelections ts ON cr.calWId = ts.WeekSelectionId WHERE ProviderId=@0 AND isActive=@1", providerid, true);
        if (records.Any())
            {

    In Visual Studio I can sometimes find what it need by hitting ALT SHFT F10, but that doesn't work here.

    Thursday, October 2, 2014 12:30 PM

Answers

  • User-821857111 posted

    Add 

    using System.Linq;

    to the top of the file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 2, 2014 2:39 PM

All replies

  • User-821857111 posted

    Add 

    using System.Linq;

    to the top of the file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 2, 2014 2:39 PM
  • User379720387 posted

    thanks.

    Thursday, October 2, 2014 3:18 PM