'------------------------------------------------------------------------------
'
' This code was generated by a tool.
' Runtime Version: 1.0.3705.0
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
'
'------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports System
Imports System.Data
Imports System.Runtime.Serialization
Imports System.Xml
_
Public Class Authors
Inherits DataSet
Private tableAuthors As AuthorsDataTable
Private tableBooks As BooksDataTable
Private relationAuthorsBooks As DataRelation
Public Sub New()
MyBase.New
Me.InitClass
Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New
Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(System.String)),String)
If (Not (strSchema) Is Nothing) Then
Dim ds As DataSet = New DataSet
ds.ReadXmlSchema(New XmlTextReader(New System.IO.StringReader(strSchema)))
If (Not (ds.Tables("Authors")) Is Nothing) Then
Me.Tables.Add(New AuthorsDataTable(ds.Tables("Authors")))
End If
If (Not (ds.Tables("Books")) Is Nothing) Then
Me.Tables.Add(New BooksDataTable(ds.Tables("Books")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
Me.InitVars
Else
Me.InitClass
End If
Me.GetSerializationData(info, context)
Dim schemaChangedHandler As System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChanged, schemaChangedHandler
AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
End Sub
_
Public ReadOnly Property Authors As AuthorsDataTable
Get
Return Me.tableAuthors
End Get
End Property
_
Public ReadOnly Property Books As BooksDataTable
Get
Return Me.tableBooks
End Get
End Property
Public Overrides Function Clone() As DataSet
Dim cln As Authors = CType(MyBase.Clone,Authors)
cln.InitVars
Return cln
End Function
Protected Overrides Function ShouldSerializeTables() As Boolean
Return false
End Function
Protected Overrides Function ShouldSerializeRelations() As Boolean
Return false
End Function
Protected Overrides Sub ReadXmlSerializable(ByVal reader As XmlReader)
Me.Reset
Dim ds As DataSet = New DataSet
ds.ReadXml(reader)
If (Not (ds.Tables("Authors")) Is Nothing) Then
Me.Tables.Add(New AuthorsDataTable(ds.Tables("Authors")))
End If
If (Not (ds.Tables("Books")) Is Nothing) Then
Me.Tables.Add(New BooksDataTable(ds.Tables("Books")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaAction.Add)
Me.InitVars
End Sub
Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema
Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
Me.WriteXmlSchema(New XmlTextWriter(stream, Nothing))
stream.Position = 0
Return System.Xml.Schema.XmlSchema.Read(New XmlTextReader(stream), Nothing)
End Function
Friend Sub InitVars()
Me.tableAuthors = CType(Me.Tables("Authors"),AuthorsDataTable)
If (Not (Me.tableAuthors) Is Nothing) Then
Me.tableAuthors.InitVars
End If
Me.tableBooks = CType(Me.Tables("Books"),BooksDataTable)
If (Not (Me.tableBooks) Is Nothing) Then
Me.tableBooks.InitVars
End If
Me.relationAuthorsBooks = Me.Relations("AuthorsBooks")
End Sub
Private Sub InitClass()
Me.DataSetName = "Authors"
Me.Prefix = ""
Me.Namespace = "http://www.tempuri.org/Authors.xsd"
Me.Locale = New System.Globalization.CultureInfo("ar-EG")
Me.CaseSensitive = false
Me.EnforceConstraints = true
Me.tableAuthors = New AuthorsDataTable
Me.Tables.Add(Me.tableAuthors)
Me.tableBooks = New BooksDataTable
Me.Tables.Add(Me.tableBooks)
Dim fkc As ForeignKeyConstraint
fkc = New ForeignKeyConstraint("AuthorsBooks", New DataColumn() {Me.tableAuthors.IDColumn}, New DataColumn() {Me.tableBooks.AuthorIDColumn})
Me.tableBooks.Constraints.Add(fkc)
fkc.AcceptRejectRule = AcceptRejectRule.None
fkc.DeleteRule = Rule.Cascade
fkc.UpdateRule = Rule.Cascade
Me.relationAuthorsBooks = New DataRelation("AuthorsBooks", New DataColumn() {Me.tableAuthors.IDColumn}, New DataColumn() {Me.tableBooks.AuthorIDColumn}, false)
Me.Relations.Add(Me.relationAuthorsBooks)
End Sub
Private Function ShouldSerializeAuthors() As Boolean
Return false
End Function
Private Function ShouldSerializeBooks() As Boolean
Return false
End Function
Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.CollectionChangeEventArgs)
If (e.Action = System.ComponentModel.CollectionChangeAction.Remove) Then
Me.InitVars
End If
End Sub
Public Delegate Sub AuthorsRowChangeEventHandler(ByVal sender As Object, ByVal e As AuthorsRowChangeEvent)
Public Delegate Sub BooksRowChangeEventHandler(ByVal sender As Object, ByVal e As BooksRowChangeEvent)
_
Public Class AuthorsDataTable
Inherits DataTable
Implements System.Collections.IEnumerable
Private columnID As DataColumn
Private columnAuthor As DataColumn
Friend Sub New()
MyBase.New("Authors")
Me.InitClass
End Sub
Friend Sub New(ByVal table As DataTable)
MyBase.New(table.TableName)
If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
Me.CaseSensitive = table.CaseSensitive
End If
If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
Me.Locale = table.Locale
End If
If (table.Namespace <> table.DataSet.Namespace) Then
Me.Namespace = table.Namespace
End If
Me.Prefix = table.Prefix
Me.MinimumCapacity = table.MinimumCapacity
Me.DisplayExpression = table.DisplayExpression
End Sub
_
Public ReadOnly Property Count As Integer
Get
Return Me.Rows.Count
End Get
End Property
Friend ReadOnly Property IDColumn As DataColumn
Get
Return Me.columnID
End Get
End Property
Friend ReadOnly Property AuthorColumn As DataColumn
Get
Return Me.columnAuthor
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As AuthorsRow
Get
Return CType(Me.Rows(index),AuthorsRow)
End Get
End Property
Public Event AuthorsRowChanged As AuthorsRowChangeEventHandler
Public Event AuthorsRowChanging As AuthorsRowChangeEventHandler
Public Event AuthorsRowDeleted As AuthorsRowChangeEventHandler
Public Event AuthorsRowDeleting As AuthorsRowChangeEventHandler
Public Overloads Sub AddAuthorsRow(ByVal row As AuthorsRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function AddAuthorsRow(ByVal Author As String) As AuthorsRow
Dim rowAuthorsRow As AuthorsRow = CType(Me.NewRow,AuthorsRow)
rowAuthorsRow.ItemArray = New Object() {Nothing, Author}
Me.Rows.Add(rowAuthorsRow)
Return rowAuthorsRow
End Function
Public Function FindByID(ByVal ID As Integer) As AuthorsRow
Return CType(Me.Rows.Find(New Object() {ID}),AuthorsRow)
End Function
Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return Me.Rows.GetEnumerator
End Function
Public Overrides Function Clone() As DataTable
Dim cln As AuthorsDataTable = CType(MyBase.Clone,AuthorsDataTable)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New AuthorsDataTable
End Function
Friend Sub InitVars()
Me.columnID = Me.Columns("ID")
Me.columnAuthor = Me.Columns("Author")
End Sub
Private Sub InitClass()
Me.columnID = New DataColumn("ID", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnID)
Me.columnAuthor = New DataColumn("Author", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnAuthor)
Me.Constraints.Add(New UniqueConstraint("Constraint1", New DataColumn() {Me.columnID}, true))
Me.columnID.AutoIncrement = true
Me.columnID.AllowDBNull = false
Me.columnID.ReadOnly = true
Me.columnID.Unique = true
Me.columnAuthor.AllowDBNull = false
End Sub
Public Function NewAuthorsRow() As AuthorsRow
Return CType(Me.NewRow,AuthorsRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New AuthorsRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(AuthorsRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.AuthorsRowChangedEvent) Is Nothing) Then
RaiseEvent AuthorsRowChanged(Me, New AuthorsRowChangeEvent(CType(e.Row,AuthorsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.AuthorsRowChangingEvent) Is Nothing) Then
RaiseEvent AuthorsRowChanging(Me, New AuthorsRowChangeEvent(CType(e.Row,AuthorsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.AuthorsRowDeletedEvent) Is Nothing) Then
RaiseEvent AuthorsRowDeleted(Me, New AuthorsRowChangeEvent(CType(e.Row,AuthorsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.AuthorsRowDeletingEvent) Is Nothing) Then
RaiseEvent AuthorsRowDeleting(Me, New AuthorsRowChangeEvent(CType(e.Row,AuthorsRow), e.Action))
End If
End Sub
Public Sub RemoveAuthorsRow(ByVal row As AuthorsRow)
Me.Rows.Remove(row)
End Sub
End Class
_
Public Class AuthorsRow
Inherits DataRow
Private tableAuthors As AuthorsDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tableAuthors = CType(Me.Table,AuthorsDataTable)
End Sub
Public Property ID As Integer
Get
Return CType(Me(Me.tableAuthors.IDColumn),Integer)
End Get
Set
Me(Me.tableAuthors.IDColumn) = value
End Set
End Property
Public Property Author As String
Get
Return CType(Me(Me.tableAuthors.AuthorColumn),String)
End Get
Set
Me(Me.tableAuthors.AuthorColumn) = value
End Set
End Property
Public Function GetBooksRows() As BooksRow()
Return CType(Me.GetChildRows(Me.Table.ChildRelations("AuthorsBooks")),BooksRow())
End Function
End Class
_
Public Class AuthorsRowChangeEvent
Inherits EventArgs
Private eventRow As AuthorsRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As AuthorsRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As AuthorsRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
_
Public Class BooksDataTable
Inherits DataTable
Implements System.Collections.IEnumerable
Private columnID As DataColumn
Private columnBook As DataColumn
Private columnAuthorID As DataColumn
Friend Sub New()
MyBase.New("Books")
Me.InitClass
End Sub
Friend Sub New(ByVal table As DataTable)
MyBase.New(table.TableName)
If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
Me.CaseSensitive = table.CaseSensitive
End If
If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
Me.Locale = table.Locale
End If
If (table.Namespace <> table.DataSet.Namespace) Then
Me.Namespace = table.Namespace
End If
Me.Prefix = table.Prefix
Me.MinimumCapacity = table.MinimumCapacity
Me.DisplayExpression = table.DisplayExpression
End Sub
_
Public ReadOnly Property Count As Integer
Get
Return Me.Rows.Count
End Get
End Property
Friend ReadOnly Property IDColumn As DataColumn
Get
Return Me.columnID
End Get
End Property
Friend ReadOnly Property BookColumn As DataColumn
Get
Return Me.columnBook
End Get
End Property
Friend ReadOnly Property AuthorIDColumn As DataColumn
Get
Return Me.columnAuthorID
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As BooksRow
Get
Return CType(Me.Rows(index),BooksRow)
End Get
End Property
Public Event BooksRowChanged As BooksRowChangeEventHandler
Public Event BooksRowChanging As BooksRowChangeEventHandler
Public Event BooksRowDeleted As BooksRowChangeEventHandler
Public Event BooksRowDeleting As BooksRowChangeEventHandler
Public Overloads Sub AddBooksRow(ByVal row As BooksRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function AddBooksRow(ByVal Book As String, ByVal parentAuthorsRowByAuthorsBooks As AuthorsRow) As BooksRow
Dim rowBooksRow As BooksRow = CType(Me.NewRow,BooksRow)
rowBooksRow.ItemArray = New Object() {Nothing, Book, parentAuthorsRowByAuthorsBooks(0)}
Me.Rows.Add(rowBooksRow)
Return rowBooksRow
End Function
Public Function FindByID(ByVal ID As Integer) As BooksRow
Return CType(Me.Rows.Find(New Object() {ID}),BooksRow)
End Function
Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return Me.Rows.GetEnumerator
End Function
Public Overrides Function Clone() As DataTable
Dim cln As BooksDataTable = CType(MyBase.Clone,BooksDataTable)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New BooksDataTable
End Function
Friend Sub InitVars()
Me.columnID = Me.Columns("ID")
Me.columnBook = Me.Columns("Book")
Me.columnAuthorID = Me.Columns("AuthorID")
End Sub
Private Sub InitClass()
Me.columnID = New DataColumn("ID", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnID)
Me.columnBook = New DataColumn("Book", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnBook)
Me.columnAuthorID = New DataColumn("AuthorID", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnAuthorID)
Me.Constraints.Add(New UniqueConstraint("Constraint1", New DataColumn() {Me.columnID}, true))
Me.columnID.AutoIncrement = true
Me.columnID.AllowDBNull = false
Me.columnID.ReadOnly = true
Me.columnID.Unique = true
Me.columnBook.AllowDBNull = false
End Sub
Public Function NewBooksRow() As BooksRow
Return CType(Me.NewRow,BooksRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New BooksRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(BooksRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.BooksRowChangedEvent) Is Nothing) Then
RaiseEvent BooksRowChanged(Me, New BooksRowChangeEvent(CType(e.Row,BooksRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.BooksRowChangingEvent) Is Nothing) Then
RaiseEvent BooksRowChanging(Me, New BooksRowChangeEvent(CType(e.Row,BooksRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.BooksRowDeletedEvent) Is Nothing) Then
RaiseEvent BooksRowDeleted(Me, New BooksRowChangeEvent(CType(e.Row,BooksRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.BooksRowDeletingEvent) Is Nothing) Then
RaiseEvent BooksRowDeleting(Me, New BooksRowChangeEvent(CType(e.Row,BooksRow), e.Action))
End If
End Sub
Public Sub RemoveBooksRow(ByVal row As BooksRow)
Me.Rows.Remove(row)
End Sub
End Class
_
Public Class BooksRow
Inherits DataRow
Private tableBooks As BooksDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tableBooks = CType(Me.Table,BooksDataTable)
End Sub
Public Property ID As Integer
Get
Return CType(Me(Me.tableBooks.IDColumn),Integer)
End Get
Set
Me(Me.tableBooks.IDColumn) = value
End Set
End Property
Public Property Book As String
Get
Return CType(Me(Me.tableBooks.BookColumn),String)
End Get
Set
Me(Me.tableBooks.BookColumn) = value
End Set
End Property
Public Property AuthorID As Integer
Get
Try
Return CType(Me(Me.tableBooks.AuthorIDColumn),Integer)
Catch e As InvalidCastException
Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
End Try
End Get
Set
Me(Me.tableBooks.AuthorIDColumn) = value
End Set
End Property
Public Property AuthorsRow As AuthorsRow
Get
Return CType(Me.GetParentRow(Me.Table.ParentRelations("AuthorsBooks")),AuthorsRow)
End Get
Set
Me.SetParentRow(value, Me.Table.ParentRelations("AuthorsBooks"))
End Set
End Property
Public Function IsAuthorIDNull() As Boolean
Return Me.IsNull(Me.tableBooks.AuthorIDColumn)
End Function
Public Sub SetAuthorIDNull()
Me(Me.tableBooks.AuthorIDColumn) = System.Convert.DBNull
End Sub
End Class
_
Public Class BooksRowChangeEvent
Inherits EventArgs
Private eventRow As BooksRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As BooksRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As BooksRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
End Class