This question is locked. New answers and comments are not allowed.
We have a object model which includes many Strongly typed collection classes. We are exploring using OpenAccess for persistence and used the mapping forward wizard to get started but it does not seem to be able to get it going...
It creates the tables in the database (SQL Server 2005 Express) but when I add items to the strong typed collection, items are not added to the database...
The following are 3 classes I'm using for the testing.... and the code to add items to the strong typed collection PSUsers
Project Class
PSUser Item
This is the code for a button to add item to the PSUSers collection
Any pointers are welcome.
It creates the tables in the database (SQL Server 2005 Express) but when I add items to the strong typed collection, items are not added to the database...
The following are 3 classes I'm using for the testing.... and the code to add items to the strong typed collection PSUsers
Project Class
Option Strict Off |
Option Explicit On |
Imports System |
<Telerik.OpenAccess.Persistent()> Public Class Project |
<Telerik.OpenAccess.SerializeToBlob()> Private m_strName As String = "" |
Private m_strDescription As String = "" |
<Telerik.OpenAccess.Transient()> Private m_PSUsers As New PSUsers |
Public Property Description() As String |
Get |
Return m_strDescription |
End Get |
Set(ByVal Value As String) |
m_strDescription = Value |
End Set |
End Property |
Public Property Name() As String |
Get |
Return m_strName |
End Get |
Set(ByVal Value As String) |
m_strName = Value |
End Set |
End Property |
Public ReadOnly Property PSUsers() As PSUsers |
Get |
Return m_PSUsers |
End Get |
End Property |
Protected Overrides Sub Finalize() |
m_PSUsers = Nothing |
End Sub |
End Class |
PSUsers Collection Class
Option Strict Off |
Option Explicit On |
Imports Microsoft.VisualBasic |
Imports System |
Imports System.Collections |
Public Class PSUsers |
Inherits CollectionBase |
Default Public Property Item(ByVal Index As Integer) As PSUser |
Get |
Return CType(List.Item(Index), PSUser) |
End Get |
Set(ByVal Value As PSUser) |
List.Item(Index) = Value |
End Set |
End Property |
Public Function Add(ByVal Item As PSUser) As Integer |
Return List.Add(Item) |
End Function |
End Class |
PSUser Item
Option Strict Off |
Option Explicit On |
Imports System |
<Telerik.OpenAccess.Persistent()> Public Class PSUser |
Private m_strUsername As String = "" |
Private m_strName As String = "" |
Private m_strDescription As String = "" |
Public Property Username() As String |
Get |
Return m_strUsername |
End Get |
Set(ByVal Value As String) |
m_strUsername = Value |
End Set |
End Property |
Public Property Name() As String |
Get |
Return m_strName |
End Get |
Set(ByVal Value As String) |
m_strName = Value |
End Set |
End Property |
Public Property Description() As String |
Get |
Return m_strDescription |
End Get |
Set(ByVal Value As String) |
m_strDescription = Value |
End Set |
End Property |
End Class |
This is the code for a button to add item to the PSUSers collection
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click |
Dim myUser As PSUser = New PSUser ' PSUser = New PSUser 'PS2Project.PSUsers.Add() |
Dim lCount As Integer |
PS2Project.PSUsers.Add(New PSUser) |
lCount = PS2Project.PSUsers.Count |
PS2Project.PSUsers.Item(lCount - 1).Username = "User" & lCount |
PS2Project.PSUsers.Item(lCount - 1).Description = "My Description " & lCount |
PS2Project.PSUsers.Item(lCount - 1).Name = "My Name " & lCount |
UpdateGUI() |
End Sub |
Any pointers are welcome.