This is a migrated thread and some comments may be shown as answers.

supplied instance is not of type Telerik.OpenAccess.SPI.dataobjects.PersistenceCapable

2 Answers 155 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Eric Moore
Top achievements
Rank 1
Eric Moore asked on 24 Sep 2010, 03:51 PM

 

 

I am getting this error on the following code
The supplied instance is not of type Telerik.OpenAccess.SPI.dataobjects.PersistenceCapable (ShopMaintenance.Scheduled+Task). Are you trying to add a wrong object or is the assembly not enhanced?

//Find all "Daily" tasks from the TaskPool table and populate the calendar with them

 

 

 

public static void Daily_Tasks(){

 

 

 

ShopMaintenanceEntityDiagrams context = new ShopMaintenanceEntityDiagrams();

 

 

 

IQueryable<TaskPool> query = from c in context.TaskPools

 

 

 

where c.Cycle == "Daily"

 

 

 

select c;

 

 

 

foreach (TaskPool taskpool in query)

 

{

 

 

int months = 12;

 

 

 

int days = DateTime.DaysInMonth(DateTime.Now.Year, months);

 

 

 

while (months > 0)

 

{

 

 

while (days > 0)

 

{

 

 

DateTime daily = new DateTime(DateTime.Now.Year, months, days, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

 

 

 

switch (daily.DayOfWeek)

 

{

 

 

case DayOfWeek.Saturday:

 

 

 

break;

 

 

 

case DayOfWeek.Sunday:

 

 

 

break;

 

 

 

default:

 

 

 

Calendar.Appointments.Add(new Calendar(taskpool.ID, taskpool.Name, taskpool.Notes, daily, daily.AddHours(1)));

 

 

 

Task task = new Task();

 

task.Id =

 

Guid.NewGuid().ToString();

 

task.TaskName = taskpool.Name;

task.TaskNotes = taskpool.Notes;

task.Start = daily;

task.End = daily.AddHours(1);

context.Add(task);

context.SaveChanges();

 

 

break;

 

}

 

days--;

}

 

 

if (months >= 1)

 

{

months--;

 

 

if (months != 0)

 

{

days =

 

DateTime.DaysInMonth(DateTime.Now.Year, months);

 

}

}

}

}


Any thoughts? Thanks!


Eric

2 Answers, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 29 Sep 2010, 06:48 PM
Hello Eric Moore,

Could you confirm that the Task class is part of the domain model? The provided from you error message reports that this class is not marked as PersistenceCapable. There are two possible reasons for this behavior:
1. Class Task is not part of the OpenAccess domain model;
2. The project which contains this class is not enhanced correctly;
An object of non persistent type can't be added in the OpenAccessContext and later persisted in the database.
If the class is part of domain model but it is not enhanced correctly we would like to ask you to provide us with a sample application which demonstrates this issue if possible.
We are looking forward to your reply.

Greetings,
Damyan Bogoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Eric Moore
Top achievements
Rank 1
answered on 04 Oct 2010, 03:29 PM
Sorry for the delayed response. I have submitted a ticket and attached a copy of my project there. Thank you.


Eric
Tags
Scheduler
Asked by
Eric Moore
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Eric Moore
Top achievements
Rank 1
Share this question
or