search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Simple Database Question

Asked by brandon
12 years ago.

Hi I'm using MVC3 and I want to take events from a database that stores Appointments that are in certain conference rooms. The Appointments have all the fields that Events do and then some. I just want to know how to use my database directly instead of putting the data into a DataTable like in your example(s) and in the EventManager class. Thanks

Answer posted by Dan Letecky [DayPilot]
12 years ago.

Hi brandon,

Yes, you can load the data directly to Events property. It accepts any IEnumerable. You only need to map the object properties using DataIdField, DataStartField, etc. See an example (using LINQ) from here:

http://kb.daypilot.org/67316/how-to-show-an-event-calendar-in-asp-net-mvc-3-razor/

class Dpc : DayPilotCalendar
{
  protected override void OnInit(InitArgs e)
  {
    var db = new DataClasses1DataContext();
    Events = from ev in db.events select ev;

    DataIdField = "id";
    DataTextField = "text";
    DataStartField = "eventstart";
    DataEndField = "eventend";

    Update();
  }
}
Comment posted by brandon
12 years ago.

Thanks Dan! This is really helpful. I had trouble finding much help specifically for MVC3/Razor on your website so I figured I'd just ask. And I'm glad I did. Much appreciated.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.