Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/06/2012, 07:00
Avatar de junior1920
junior1920
 
Fecha de Ingreso: noviembre-2010
Ubicación: Tumán
Mensajes: 77
Antigüedad: 14 años, 2 meses
Puntos: 1
Exclamación Clases relacionadas en VB.net !!!

Hola Sr(es). aqui nuevamente publicando un nuevo tema para dar ideas acerca de las dudas que tengo. Gracias de antemano.
Bueno el tema es que tengo 2 tablas categorias y subcategorias:
Código SQL:
Ver original
  1. CREATE TABLE categoria(
  2. idcat serial PRIMARY KEY,
  3. nom_cat CHARACTER(50),
  4. desc_cat text)
  5.  
  6. CREATE TABLE subcategoria(
  7. idsubcat serial PRIMARY KEY,
  8. nomsub_cat CHARACTER(60),
  9. idcat INTEGER,
  10. CONSTRAINT subcatego_idcat_fkey FOREIGN KEY (idcat)
  11.       REFERENCES categoria (idcat) MATCH SIMPLE
  12.       ON UPDATE NO ACTION ON DELETE NO ACTION
  13. )

esos atributos de las dos tablas los tengo en diferentes clases
clase categoria
Código vb:
Ver original
  1. Imports System.Collections.Generic
  2. Imports System.Linq
  3. Imports System.Text
  4. Namespace Entities
  5. Public Class categoriaEntities
  6.     Private idcat As Integer
  7.     Private nom_cat As String
  8.     Private desc_cat As String
  9.     '--------------------------
  10.     Public Property gidcat
  11.         Get
  12.             Return idcat
  13.         End Get
  14.         Set(ByVal value)
  15.             idcat=value
  16.         End Set
  17.     End Property
  18.     '--------------------------
  19.     Public Property gnom_cat
  20.         Get
  21.             Return nom_cat
  22.         End Get
  23.         Set(ByVal value)
  24.             nom_cat=value
  25.         End Set
  26.     End Property
  27.     '--------------------------
  28.     Public Property gdesc_cat
  29.         Get
  30.             return desc_cat
  31.         End Get
  32.         Set(ByVal value)
  33.             desc_cat=value
  34.         End Set
  35.     End Property
  36.     '--------------------------
  37. End Class
  38. End Namespace

y la tabla subcategoria en esta clase
Código vb:
Ver original
  1. Imports System.Collections.Generic
  2. Imports System.Linq
  3. Imports System.Text
  4. Namespace Entities
  5. Public Class subcategoriaEntities
  6.     Private idsubcat As Integer
  7.     Private idcat As Integer
  8.     Private nomsub_cat As String
  9.     '--------------------------
  10.     Public Property gidsubcat
  11.         Get
  12.             Return idsubcat
  13.         End Get
  14.         Set(ByVal value)
  15.             idsubcat=value
  16.         End Set
  17.     End Property
  18.     '--------------------------
  19.     Public Property gidcat
  20.         Get
  21.             Return idcat
  22.         End Get
  23.         Set(ByVal value)
  24.             idcat=value
  25.         End Set
  26.     End Property
  27.     '--------------------------
  28.     Public Property gnomsub_cat
  29.         Get
  30.             return nomsub_cat
  31.         End Get
  32.         Set(ByVal value)
  33.             nomsub_cat=value
  34.         End Set
  35.     End Property
  36.     '--------------------------
  37. End Class
  38. End Namespace

Bien ahora mi problema es como hacer para que esas dos clases me retorne los valores que yo requiero, po ejemplo quiero hacer un listado de subcategorias con sus categorias e intente hacerlo pero no me da resultado lo enlaze haciendo que el idcat sea tipo entidad y tambien intente hacer esto public overridable.....
pero eso me enviaba un valor en blanco

Ahora lo que realmente quiero es usar esas dos calses para poder hacer un listado y mostra en un datagridview por que algunos dicen crea vistas y yo pienso y entonces por o para que se crean clases con los campos de tabla o acaso solo se hace eso para hacer insert,update o delete
esa es mi duda por el momento...