Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:03:09+00:00 2026-05-30T18:03:09+00:00

My code : var db = Database.Open(dbase); var result = db.Query(SELECT event_id, description, title,

  • 0

My code :

var db = Database.Open("dbase");
var result = db.Query("SELECT event_id, description, title, event_start, event_end 
                       FROM event 
                       WHERE event_start >= "+ start + " AND event_end <= "+ @end);

foreach(var record in result)
{
   CalendarEvent cevent = new CalendarEvent();
   cevent.id = result.event_id; //error is thrown here
}

Error message :

CS1061: ‘System.Collections.Generic.IEnumerable’ does not
contain a definition for ‘event_id’ and no extension method ‘event_id’
accepting a first argument of type
‘System.Collections.Generic.IEnumerable’ could be found (are
you missing a using directive or an assembly reference?)

In my code I have :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using WebMatrix.Data;

What is causing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:03:10+00:00Added an answer on May 30, 2026 at 6:03 pm

    Well to start with, you probably meant record.event_id instead of result.event_id. Your code would be clearer if you changed result to results, given that it’s the sequence of results.

    However, that’s just going to move the problem on one stage. Database.Query returns an IEnumerable<object>, so the type of record is going to be object… and object doesn’t have a member called event_id either.

    The documentation for Database.Query is pretty vague – it’s possible that it’s returning dynamic objects though. Try this:

    foreach (dynamic record in result)
    {
            CalendarEvent cevent = new CalendarEvent();
            cevent.id = record.event_id;
    }
    

    EDIT: If record.event_id is working even without converting to dynamic, then it’s possible that the effective result type is IEnumerable<dynamic> and MSDN is just not being terribly helpful.

    However, there’s still a problem in your code: it’s a bad idea to include your parameter values directly in your SQL like that:

    • Mixing code and data is a bad idea in terms of code cleanliness
    • You need to make sure that dates, numbers etc are in the right format
    • It opens you up to SQL injection attacks

    Instead, you should use a parameterized query like this:

    var result = db.Query(
         "SELECT event_id, description, title, event_start, event_end FROM event " +
         "where event_start >= ? AND event_end <= ?",
         start, end);        
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With this code: var db = google.gears.factory.create('beta.database'); db.open('cominar'); db.execute('CREATE TABLE IF NOT EXISTS Ajax
Code: var result = db.rows.Take(30).ToList().Select(a => AMethod(a)); db.rows.Take(30) is Linq-To-SQL I am using ToList()
I have this simple example code: var request = mozIndexedDB.open('MyTestDatabase'); request.onsuccess = function(event){ var
How do you add named SQL Parameters in WebPages Framework? var db = Database.Open(database);
I am trying to get the data from database by using the below code.....
See code: var file1 = 50.xsl; var file2 = 30.doc; getFileExtension(file1); //returns xsl getFileExtension(file2);
for example this code var html = <p>This text is <a href=#> good</a></p>; var
Suppose I have this code: var myArray = new Object(); myArray["firstname"] = "Bob"; myArray["lastname"]
in the following code : var benq:Base64Encoder = new Base64Encoder(); benq.encode(force,0,5); var tmp:String =
Given the following code: var people = new List<person>(){ new person { Name =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.