I have a problem while Removing an object in the Scope.
Error Code:
Delete failed: Telerik.OpenAccess.RT.sql.SQLException: The DELETE statement |
conflicted with the REFERENCE constraint "ref_project_tasks_tasks". The conflict |
occurred in database "JumpPMC", table "dbo.project_tasks", column |
'tasks_id'.<BR>The statement has been terminated.<BR> at |
Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate()<BR> |
at |
OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate()<BR> |
at |
OpenAccessRuntime.Relational.RelationalStorageManager.deleteRow(PreparedStatement |
ps, RelationalOID oid, String sql)<BR>Row: <A |
href="mailto:GenericOID@4">GenericOID@4</A> Tasks tasks_id=1<BR>DELETE FROM |
[tasks] WHERE [tasks_id] = ?<BR>(set event logging to all to see parameter |
values) Telerik.OpenAccess.RT.sql.SQLException: The DELETE statement conflicted |
with the REFERENCE constraint "ref_project_tasks_tasks". The conflict occurred |
in database "JumpPMC", table "dbo.project_tasks", column 'tasks_id'.<BR>The |
statement has been terminated.<BR> at |
Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate()<BR> |
at |
OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate()<BR> |
at |
OpenAccessRuntime.Relational.RelationalStorageManager.deleteRow(PreparedStatement |
ps, RelationalOID oid, String sql)<BR> |
i am getting this error when i tried to remove the Task Item from collection.
from th code
IObjectScope Scope = ObjectScopeProvider1.GetNewObjectScope();
Scope.Transaction.Begin();
List<JumpPMC_Library.Tasks> taskses = (from c in Scope.Extent<Tasks>()
where c.tuid == Id
select c).ToList();
Scope.Remove(taskses[0]);
Scope.Transaction.Commit();
I am using Forward mapping, my classes are
"Project" class:
[Telerik.OpenAccess.Persistent]
public class Project
{
public Project()
{
myTasks = new List<Tasks>();
}
public Guid puid = Guid.Empty;
public string title = string.Empty;
private string description = string.Empty;
private IList<Tasks> myTasks;
public string Title
{
get
{
return title;
}
set
{
title = value;
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
public IList<Tasks> MyTasks
{
get
{
return myTasks;
}
set
{
myTasks = value;
}
}
public Guid PUid
{
get { return puid; }
set { puid = value; }
}
}
and Tasks Class is like:
[Telerik.OpenAccess.Persistent]
public class Tasks
{
public Tasks()
{
Assignee = new Resource();
resource = new Resource();
duration = 0;
Edits = new List<TaskEdits>();
}
private Project myproject;
public Guid tuid = Guid.Empty;
private string name = string.Empty;
private string description = string.Empty;
private Resource assignee;
private Resource resource;
private DateTime startDate = DateTime.MinValue;
private int duration;
private string project_name = string.Empty;
private IList<TaskEdits> edits = null;
public string Name
{
get
{
return name ;
}
set
{
name = value;
}
}
public string Description
{
get { return description; }
set { description = value; }
}
public Resource Assignee
{
get
{
return assignee;
}
set
{
assignee = value;
}
}
public DateTime StartDate
{
get
{
return startDate;
}
set
{
startDate = value;
}
}
public int Duration
{
get { return duration; }
set { duration = value; }
}
public Resource Resource
{
get { return resource; }
set { resource = value; }
}
public string Project_Name
{
get{ return project_name;}
set { project_name = value;}
}
public Guid TUID
{
get{ return tuid;}
set { tuid = value; }
}
public IList<TaskEdits> Edits
{
get { return edits; }
set { edits = value; }
}
public Project MYProject
{
get { return myproject; }
set { myproject = value; }
}
}