Clase Ejemplo de como Enlazar a una BD y una Tabla Con System.Data.LinQ
Option Strict On Option Explicit On Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Data.Linq Imports System.Data.Linq.Mapping Imports System.Linq Imports System.Linq.Expressions Imports System.Reflection Namespace PhoneAppLinQ Partial Public Class MyBD Inherits System.Data.Linq.DataContext Private Shared mappingSource As System.Data.Linq.Mapping.MappingSource = New AttributeMappingSource Public Sub New(ByVal connection As String) MyBase.New(connection, mappingSource) End Sub Public Sub New(ByVal connection As String, ByVal mappingSource As System.Data.Linq.Mapping.MappingSource) MyBase.New(connection, mappingSource) End Sub Public ReadOnly Property Contactenos() As System.Data.Linq.Table(Of Contacteno) Get Return Me.GetTable(Of Contacteno)() End Get End Property End Class <Table(Name:="Contactenos")> _ Partial Public Class Contacteno Private _Nombres As String Private _Dni As String Private _Email As String Public Sub New() MyBase.New End Sub <Column(Storage:="_Nombres", DbType:="NVarChar(100)")> _ Public Property Nombres() As String Get Return Me._Nombres End Get Set If (String.Equals(Me._Nombres, value) = false) Then Me._Nombres = value End If End Set End Property <Column(Storage:="_Dni", DbType:="NChar(8)")> _ Public Property Dni() As String Get Return Me._Dni End Get Set If (String.Equals(Me._Dni, value) = false) Then Me._Dni = value End If End Set End Property <Column(Storage:="_Email", DbType:="NVarChar(20)")> _ Public Property Email() As String Get Return Me._Email End Get Set If (String.Equals(Me._Email, value) = false) Then Me._Email = value End If End Set End Property End Class End Namespace
Comentarios
Publicar un comentario