| C# VB.NET |
// Create the two instance of the ObjectContexts. The first instance connects to // the first database and the second to the second one. ObjectContext context1 = new ObjectContext(new AccessStorage("C:\\", "db1.mdb")); ObjectContext context2 = new ObjectContext(new AccessStorage("C:\\", "db2.mdb"));
// Create an ObjectReader to read all User persistent objects from the first // database. using (ObjectReader<User> or = context1.GetObjectReader<User>()) { // Loop over all user... foreach(User user in or) { // ... and insert them in the second database. context2.PersistChanges(user); } } ' Create the two instance of the ObjectContexts. The first instance connects to ' the first database and the second to the second one. Dim context1 = New ObjectContext(New AccessStorage("C:\", "db1.mdb")) Dim context2 = New ObjectContext(New AccessStorage("C:\", "db2.mdb"))
' Create an ObjectReader to read all User persistent objects from the first ' database. Dim objectReader = context1.GetObjectReader(Of User)()
Try ' Loop over all user... For Each user In objectReader ' ... and insert them in the second database. context2.PersistChanges(user) Next Finally
End Try |