there is a way to know the identifier column identifier of the record inserted through InsertOnSubmitin advance, for example. before calling datasource SubmitChanges?
Imagine that I am filling in some kind of hierarchy in the database, but I would not want to send changes for each recursive call of each child element of the node (for example, if I had a directory table and a file table and I recreated my file system structure in the database )
I would like to do it this way, so I create a Directory object, set its name and attributes, then InsertOnSubmitto the DataContext.Directories collection, and then refer to Directory.ID in its child files. Currently, I need to call InsertOnSubmit to insert the "directory" into the database, and the database mapping fills its identifier column. But this creates a lot of transactions and database access, and I believe that if I did this in a batch package, performance would be better.
What I would like to do is somehow use Directory.ID before making the changes, create all my File and Directory objects in advance, and then make a large file that puts all the data in the database. I am also open to solving this problem using a stored procedure; I assume that performance will be even better if all operations are performed directly in the database.
source
share