Hello all,
I am currently writing a page that has to persist a delete status for items in a cart. When I click on the delete button, it changes the status of the item to a pending deletion status. Then, the user at another date or from another role, will confirm the delete and physically delete the record from the database.
I was trying to overload DataPortal_Delete with criteria other than a SingleCriteria object and I received the error message: "Value cannot be null. Parameter name: key"
It doesn't actually get to the DataPortal_Delete overload. From other posts and what Rocky has said, maybe it is getting confused? Both overloads take in a single string, however one uses the SingleCriteria and the other just uses string so I'm not sure if that's the problem or not.
Below is my code:
Public Shared Sub MarkForDelete(ByVal barcode As String)
DataPortal.Delete(New SingleCriteria(Of Item, String)(barcode))
End Sub
Public Shared Sub DeleteItem(ByVal pBarCode As String)
DataPortal.Delete(pBarCode)
End Sub
<Transactional(TransactionalTypes.TransactionScope)> _
Private Overloads Sub DataPortal_Delete(ByVal criteria As SingleCriteria(Of Item, String))
Using ctx = ContextManager(Of DB.DalLinq.dbDataContext).GetManager(DB.DalLinq.Database.db)
ctx.DataContext.UpdateItemMarkDeleted(criteria.Value)
End Using
End Sub
<Transactional(TransactionalTypes.TransactionScope)> _
Private Overloads Sub DataPortal_Delete(ByVal barcode As String)
Using ctx = ContextManager(Of DB.DalLinq.dbDataContext).GetManager(DB.DalLinq.Database.db)
ctx.DataContext.DeleteItem(barcode)
End Using
End Sub
Thanks in advance for any responses.
[Update] A workaround I implemented was using LINQ to SQL within my MarkForDelete method which called the stored procedure to update the status of the particular item and kept DataPortal_Delete as the way to physically delete the record.
On the UI, I combined the button handlers by casting the sender to my LinkButton and checking the IDs to determine which method I would call...MarkForDelete or DeleteItem.
The result was a consolidation of code and a fix to the solution. Not sure if this is the proper way to do what i was asking about but for now it works.
Any feedback is appreciated. Thanks
Copyright (c) Marimer LLC