I have a .NET 2.0 app using version 2.0.0.61120. It has a grid that's bound to an EntityView which I use to filter a collection. Whenever I try to delete a record the collection I get an exception. Help on how to get around this would be appreciated. Here is my code that creates the EntityView
public JobAttorneyCollection CoCounselAttorneys
{
get
{
EntityView<JobAttorneyEntity> attorneyView = new EntityView<JobAttorneyEntity>(this.JobAttorneys, JobAttorneyFields.AttorneyTypeId == 3);
return (JobAttorneyCollection)attorneyView.ToEntityCollection();
}
}
This is my code to delete a record from this collection:
JobAttorneyEntity coCouncel = (JobAttorneyEntity)coCounselBindingSource.Current;
_subject.CurrentJob.JobAttorneys.Remove(coCouncel);
coCouncel.Delete();
When I delete a record from this EntityView I get this I get this exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> SD.LLBLGen.Pro.ORMSupportClasses.ORMEntityIsDeletedException: This entity is deleted from the database and can't be used in logic.
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.GetCurrentFieldValue(Int32 fieldIndex)
at LCS.CaseManager.BLL.EntityClasses.JobAttorneyEntityBase.get_CounselTypeId() in C:\Projects\Legal Copy Services\CaseManager\LCS.CaseManager.BLL\EntityBaseClasses\JobAttorneyEntityBase.cs:line 1412