Mapping party pattern con EF4

rated by 0 users
This post has 0 Replies | 1 Follower

Top 25 Partecipanti
Post 44
Punteggio 685
4Net Posted: 07-28-2010 11.47

Un saluto a tutti.
Come da oggetto verrei mappare le mie entita fatte su Party pattern verso il mio db con EF4.
Ho dei problemi con alcune proprietà delle classi derivate, proprietà che vorrei escludere dal mapping.
Mi spiego con un esempio:
Tanto per cominciare specifico che sto provando ad usare classi poco fatte a mano ricostruite dentro EDMX usato solo per il mapping (come su agorà e nsk).

public abstract Party
{
...
protected PartyType Type { get; set; }
protected string Description1 { get; set; }
protected string Description2 { get; set; }
...
}

public class Company : Party
{
   public Company()
   {
    Type = PartyType.LegalPerson;
   }
...
   public string Name { get { return Description1; } set { Description1 = value; } }
   public string Description { get { return Description2; } set { Description2 = value; } }
...
}

non so quanto sia bella questa soluzione comunque...
nel mio EDXM ho già mappato completamente la classe Party quindi mi aspettavo di non dover mappare le proprietà Name e Description della classe che deriva da Party.
Ho provato con StoreGeneratedPattern=Computed ma ho sempre l'errore "..not mapping specified..."
Lo stesso problema si presenta con una proprieta enum della classe party che non voglio mappare perchè ho già mappato al suo posto una di tipo Int che le fa da wrapper.
Usando il papping code only sarebbe possibile raggiungere il mio scopo?

  • | Punteggio Post: 5
Pagina 1 di 1 (1 elementi) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems