This question is locked. New answers and comments are not allowed.
Posted 1 day ago
hi
i have a exception when i try to add a list of object,
this is my codes:
public class
public class DCRelatedDocument |
{ |
private int FId; |
private DCDocument FDocument; |
private DCDocument FRelatedDocument; |
private string FRelationNote; |
} |
public class DCDocument |
{ |
[Telerik.OpenAccess.Transient()] |
private int transientId; |
private int FId; |
private string FTitle; |
private string FCode; |
private sbyte FIsCalculatedCode; |
[Telerik.OpenAccess.Depend()] |
private string FKeyword; |
private DateTime FShowDateTime; |
private DateTime FNotShowDateTime; |
private string FAbstract; |
private int FRevisionNumber; |
private int FRevisionPeriod; |
private DateTime FLastRevisionDateTime; |
private DateTime FFirstComingRevisionDateTime; |
private string FRevisionNote; |
private DCScope FDocumentScope; |
private DCDocumentState FDocumentState; |
private Request FRequest; |
[Telerik.OpenAccess.Depend()] |
private IList<DCDocument> FSubDocuments; |
[Telerik.OpenAccess.Depend()] |
private IList<DCDocumentGroup> FDocumentGroups; |
[Telerik.OpenAccess.Depend()] |
private IList<WFTemplateNode> FWFTemplateNodes; |
private WFTemplate FWFTemplate; |
[Telerik.OpenAccess.Depend()] |
private IList<DCDocumentRecieverCategory> FDCDocumentRecieverCategories; |
[Telerik.OpenAccess.Transient()] |
private IList<AttachmentDetail> attachmentDetails; |
[Telerik.OpenAccess.Transient()] |
private IList<DCRelatedDocument> FRelatedDocuments; |
} |
protected void Page_Load(object sender, EventArgs e) |
{ |
public void RemoveDCDocumentById(int DCDocumentId, bool commitOnEnd) |
{ |
try |
{ |
DCDocument documentToRemove = RetrieveDCDocumentById(DCDocumentId); |
if (!scope.Transaction.IsActive) |
{ |
scope.Transaction.Begin(); |
} |
foreach (DCDocument subDocument in documentToRemove.SubDocuments) |
{ |
List<AttachmentDetail> attachDetails = attachmentDetailManager.RetrieveAttachmentDetailByObjectType(subDocument).ToList(); |
attachmentDetailManager.RemoveAttachementDetails(attachDetails, false); |
} |
attachmentDetailManager.RemoveAttachementDetails(documentToRemove.AttachmentDetails, false); |
relatedDocumentManager.RemoveDCRelatedDocumentsByDocumentId(documentToRemove.Id, false); |
scope.Remove(documentToRemove); |
if (commitOnEnd) |
{ |
scope.Transaction.Commit(); |
} |
} |
catch (Exception ex) |
{ |
throw; |
} |
finally |
{ |
} |
} |
public void RegisterNewDCRelatedDocuments(List<DCRelatedDocument> relatedDocuments, bool CommitOnEnd) |
{ |
try |
{ |
if (!scope.Transaction.IsActive) |
{ |
scope.Transaction.Begin(); |
} |
scope.Add(relatedDocuments);<===== Exception Occured Here |
if (CommitOnEnd) |
{ |
scope.Transaction.Commit(); |
} |
} |
catch (Exception ex) |
{ |
throw; |
} |
finally |
{ |
} |
} |
DCDocument oldDoc = RetrieveDCDocumentById(33); |
DCRelatedDocument a = new DCRelatedDocument(); |
a.Document = oldDoc; |
a.RelatedDocument = docManager.RetrieveDCDocumentById(34); |
DCRelatedDocument a1 = new DCRelatedDocument(); |
a1.Document = oldDoc; |
a1.RelatedDocument = docManager.RetrieveDCDocumentById(35); |
relatedDocs.Add(a); |
relatedDocs.Add(a1); |
RegisterNewDCRelatedDocuments(relatedDocs, true); |
} |
exception occured on this line of code , when i want to add a list of objects : scope.Add(relatedDocuments);
Exception:
The supplied instance is not of type Telerik.OpenAccess.SPI.dataobjects.PersistenceCapable (System.Collections.Generic.List`1[[EandE.DocumentControl.BSL.Entities.DCRelatedDocument, EandE.DocumentControl.BSL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]). Are you trying to add a wrong object or is the assembly not enhanced?
how can i solve my problem???