0

I am unable to use AddObject(Entity) for adding new entity while working on kendo scheduler using helper. It showing error -

Does not contain a definition for 'AddObject' and no extension method for 'AddObject' accepting a first argument (missing some reference?)

public ActionResult Tasks_Create([DataSourceRequest]DataSourceRequest request, TaskViewModel task)
        {


            if (ModelState.IsValid)
            {
                using (var sampleDB = new EntitiesModel())
                {
                    //Task task_obj = new Task();

                    //Create a new Task entity and set its properties from the posted TaskViewModel
                    var entity = new Task
                    {
                        TaskID = task.TaskID,
                        Title = task.Title,
                        Start = Convert.ToString(task.Start),
                        End = Convert.ToString(task.End),
                        Description = task.Description,
                        RecurrenceRule = task.RecurrenceRule,
                        RecurrenceException = task.RecurrenceException,
                        RecurrenceID = Convert.ToString(task.RecurrenceID),
                        IsAllDay = Convert.ToString(task.IsAllDay),
                        OwnerID = Convert.ToString(task.OwnerID)
                    };


                    // Add the entity

                    sampleDB.Tasks.AddObject(entity);
                    // Insert the entity in the database
                    sampleDB.SaveChanges();
                    // Get the TaskID generated by the database
                    task.TaskID = entity.TaskID;
                }
            }
            // Return the inserted task. The scheduler needs the generated TaskID. Also return any validation errors.
            return Json(new[] { task }.ToDataSourceResult(request, ModelState));


        }
Mykola
  • 3,343
  • 6
  • 23
  • 39
Chaitanya
  • 7
  • 1
  • 5

0 Answers0