Bueno el tema es que tengo 2 tablas categorias y subcategorias:
Código SQL:
Ver original
CREATE TABLE categoria( idcat serial PRIMARY KEY, nom_cat CHARACTER(50), desc_cat text) CREATE TABLE subcategoria( idsubcat serial PRIMARY KEY, nomsub_cat CHARACTER(60), idcat INTEGER, CONSTRAINT subcatego_idcat_fkey FOREIGN KEY (idcat) REFERENCES categoria (idcat) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION )
esos atributos de las dos tablas los tengo en diferentes clases
clase categoria
Código vb:
Ver original
Imports System.Collections.Generic Imports System.Linq Imports System.Text Namespace Entities Public Class categoriaEntities Private idcat As Integer Private nom_cat As String Private desc_cat As String '-------------------------- Public Property gidcat Get Return idcat End Get Set(ByVal value) idcat=value End Set End Property '-------------------------- Public Property gnom_cat Get Return nom_cat End Get Set(ByVal value) nom_cat=value End Set End Property '-------------------------- Public Property gdesc_cat Get return desc_cat End Get Set(ByVal value) desc_cat=value End Set End Property '-------------------------- End Class End Namespace
y la tabla subcategoria en esta clase
Código vb:
Ver original
Imports System.Collections.Generic Imports System.Linq Imports System.Text Namespace Entities Public Class subcategoriaEntities Private idsubcat As Integer Private idcat As Integer Private nomsub_cat As String '-------------------------- Public Property gidsubcat Get Return idsubcat End Get Set(ByVal value) idsubcat=value End Set End Property '-------------------------- Public Property gidcat Get Return idcat End Get Set(ByVal value) idcat=value End Set End Property '-------------------------- Public Property gnomsub_cat Get return nomsub_cat End Get Set(ByVal value) nomsub_cat=value End Set End Property '-------------------------- End Class 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...