Relationships between classes without DBObjectModel

Topics: Developer Forum, Project Management Forum, User Forum
Feb 5, 2009 at 11:33 AM

Good morning

I am using the old base in DBEntry to map my tables.

I want to know how can I make the following classes


Table: Categoria
PK: Codigo_Categoria

Class: Categoria 
Property: IdCategoria PK: Codigo_Categoria
Property: Name Column: Name

Table: Filiado
PK: Codigo_Filiado
FK: Codigo_Categoria

Class: Filiado

Property: IdFiliado PK: Codigo_Filiado
Property: IdCategoria FK: Codigo_Categoria
Property: Name Column: Name
Property: Categoria Object: Categoria

Filiado want in the class have an object "Categoria " as I do that?

I could spend an example please.

Feb 5, 2009 at 2:40 PM
Edited Feb 5, 2009 at 2:43 PM
DbEntry doesn't support relationship without DbObjectModel.
So you need handle it by yourself like:

public class Categoria : IDbObject
    [DbKey, DbColumn("Codigo_Categoria")] public int IdCategoria;
    public string Name;

public class Filiado : IDbObject
    [DbKey, DbColumn("Codigo_Filiado")] public int IdCategoria;
    [DbColumn("Codigo_Categoria")] public int IdCategoria;
    public string Name;

Categoria c = DbEntry.GetObject<Categoria>(1);
List<Filiado> fs = DbEntry.From<Filiado>().Where(CK.K["Codigo_Categoria"] == c.IdCategoria).Select();