M
MichalR
Welcome
I have some solution and I wonder if it's proper (I haven't an
opportunity to test it in production env. yet).
There is a single typed dataset instance, stored in asp.net Cache. It is
referenced by about 30 users. There are two tables - Table1 and Table2
with the master-detail relation (Table1.id - Table2.Table1id). Now I
want to delete Table1 record and all child records form Table2 without
using dataset's cascade delete feature (ds is a typed dataset reference,
dataAdapterT1, dataAdapterT2 are the SqlDataAdapters, I also removed all
try/catch and SqlTransaction related code for simplicity):
.....
dim ds as dsMain=Cache("dsMain")
.....
Sub DeleteFromTable1ByID(id as integer)
SyncLock ds
dim t1r as ds.Table1Row=ds.FindByid(id)
dim t2r as ds.Table2Row
For Each t2r In t1r.GetTable2Rows()
t2r.Delete()
Next
t1r.Delete()
dataAdapterT1.Update(ds)
dataAdapterT2.Update(ds)
End SynckLock
End Sub
The question is if such usage of SyncLock is proper and will not hurt
the application performace too much. I wonder if SyncLock have sense
here at all and if maybe I should place "End SynckLock" before firing
dataadapters' update methods?
Any opionon are welcome.
Thanks,
Michal
I have some solution and I wonder if it's proper (I haven't an
opportunity to test it in production env. yet).
There is a single typed dataset instance, stored in asp.net Cache. It is
referenced by about 30 users. There are two tables - Table1 and Table2
with the master-detail relation (Table1.id - Table2.Table1id). Now I
want to delete Table1 record and all child records form Table2 without
using dataset's cascade delete feature (ds is a typed dataset reference,
dataAdapterT1, dataAdapterT2 are the SqlDataAdapters, I also removed all
try/catch and SqlTransaction related code for simplicity):
.....
dim ds as dsMain=Cache("dsMain")
.....
Sub DeleteFromTable1ByID(id as integer)
SyncLock ds
dim t1r as ds.Table1Row=ds.FindByid(id)
dim t2r as ds.Table2Row
For Each t2r In t1r.GetTable2Rows()
t2r.Delete()
Next
t1r.Delete()
dataAdapterT1.Update(ds)
dataAdapterT2.Update(ds)
End SynckLock
End Sub
The question is if such usage of SyncLock is proper and will not hurt
the application performace too much. I wonder if SyncLock have sense
here at all and if maybe I should place "End SynckLock" before firing
dataadapters' update methods?
Any opionon are welcome.
Thanks,
Michal