Wednesday, 14 August 2013

Error occured while updating field in database: An unhandled exception of type 'System.StackOverflowException' occurred in Unknown Module.in...

Error occured while updating field in database: An unhandled exception of
type 'System.StackOverflowException' occurred in Unknown Module.in...

I have a table with columns checkbox,Document name,Field & so on. In Field
column I have displayed dropdown so as I change the values in dropdown it
should be updated in table.I am passing DocumentId and crossponding
fieldId (of row)through jquery to controller.But I get this error in
Repository.cs file An unhandled exception of type
'System.StackOverflowException' occurred in Unknown Module.
This is my Controller Code
public ActionResult FieldSubmitted(long VendorId, int DocumentId,
int FieldId)
{
SubmittedDocument submittedDocument = new SubmittedDocument();
var requestedDocument =
_requestedDocumentService.GetVendorDocuments(VendorId).Where(t =>
t.DocumentID == DocumentId).FirstOrDefault();
if (requestedDocument != null)
{
submittedDocument =
_submittedDocumentService.GetVendorDocuments(VendorId).Where(t =>
t.RequestedDocumentID ==
requestedDocument.RequestedDocumentID).FirstOrDefault();
submittedDocument.FieldId = FieldId;
_submittedDocumentService.UpdateSubmittedDocument(submittedDocument);
}
return Json("", JsonRequestBehavior.AllowGet);
}
My Service
public int UpdateSubmittedDocument(SubmittedDocument
submittedDocument)
{
int a= _submittedDocumentRepository.Update(submittedDocument,
submittedDocument.SubmittedDocumentID);
return a;
}
Repository.cs
public class Repository<TObject> : IRepository<TObject>
public virtual void UpdateAuditedEntries(object obj)
{
if (CurrentUser == null)
return;
if (obj == null)
return;
var auditedEntity = obj as IAuditedEntity;
if (auditedEntity != null)
{
auditedEntity.ModifiedBy = CurrentUser.UserId;
auditedEntity.ModifiedDateTime = DateTime.Now;
obj.GetType().GetProperties().ToList().ForEach(x =>
{
var child = x.GetValue(obj);
UpdateAuditedEntries(child);
});
}
else
{
var propertyCollection = obj as ICollection;
if (propertyCollection != null)
{
foreach (object child in propertyCollection)
{
UpdateAuditedEntries(child);
}
}
}
}
I am getting error at var child = x.GetValue(obj); this line An unhandled
exception of type 'System.StackOverflowException' occurred in Unknown
Module.

No comments:

Post a Comment