I am trying to add an entry to a SQLServer db table using LINQ to SQL in my WPF application, but always get an error message related to a missing directive. Usually intellisense gives a hint of such a problem, but not this time. Here is my code with all the directives:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Collections.ObjectModel; ... ... DateTime newdate = new DateTime(2010, 2, 1); TimeSpan newtime = new TimeSpan(12, 00, 00); MyfirstdbDataContext context = new MyfirstdbDataContext(); Meeting meeting = new Meeting(); meeting.MeetID = "01.02.10_12:00"; meeting.Date = newdate; meeting.Time = newtime; context.Meetings.Add(meeting);
And I get this error:
System.Data.Linq.Table 'does not contain a definition for "Add", and the "Add" extension method cannot be found that takes the first argument of the type "System.Data.Linq.Table" (if you lack a usage directive or a reference to assembly?)
Please, what could be wrong with my code?
source share