I am not talking about transactions at database level. I woukld like to implement transactions at object level. Here is my code:
WorkQueue wq = new WorkQueue();
wq.OWNER_ID = user.EmployeeId;
wq.OWNER_NM = user.FullName;
wq.WQ_DETAILS = txtDetails.Text;
wq.SOURCE_INFO = txtSource.Text;
wq.PRIORITY_ID = Convert.ToInt32(ddlRequestType.SelectedItem.Value);
wq.PRO_ID = Convert.ToInt32(ViewState["pro_id"]);
wq.GROUP_ID = Convert.ToInt32(ViewState["cat_id"]);
wq.Save();
WQAttachment attachment = new WQAttachment();
attachment.ATTACH_SIZE = FileUpload1.PostedFile.ContentLength.ToString();
attachment.ATTACH_FILE = FileUpload1.FileBytes;
attachment.WQ_ID = wq.WQ_ID.Value;
attachment.ATTACH_FILE_NM = FileUpload1.FileName;
attachment.ATTACH_NM = "Upload test";
attachment.ATTACH_TYPE = FileUpload1.PostedFile.ContentType;
attachment.Save();
Is there a way I can wrap this in a transaction so if attachment.save fails, it should roll back wq.save. Thanks!
I see a SO answer regarding TransactionScope, Can I use this for my case above? Transactions in .net