Hi! Can anyone help me?

I could use a one to many map to solve it, but i need to transform a list 
inside child classes and the definition could be any class that implement 
IDefinition.

*Class model:*

interface IDefinition
{ }

class OrigemDados
string somethingHere;
string somethingHere2;
IDefinition definition; //just to tell me that can be any childClass1 or 
childClass2
 class ChildClass1 : IDefinition
string differentString;
List<somethingDifferent> internalList;
 class ChildClass2 : IDefinition
string anotherdifferentString;
List<anothersomethingDifferent> internalList;

*Database model:*

OrigemDados (ID, Property1, Property2)
 ChildTable1 (ID from Father, differentString, Name, AnotherProperty)

ChildTable2 (ID from Father, differentString, Year, Active)


*Sample:*
 OrigemDados origemDados = new OrigemDados();
origemDados.Id = 1
origemDados.somethingHere = "hi!";
origemDados.somethingHere2 = "new string";
origemDados.definition = new ChildClass1() 
{ 
differentString = "Child class 1", 
internalList = List<somethingDifferent>() 
{ 
new somethingDifferent() {Name = "Abc", AnotherProperty = 1 },
new somethingDifferent() {Name = "Def", AnotherProperty = 35 }
};
}

OrigemDados origemDados2 = new OrigemDados();
origemDados2.Id = 2
origemDados2.somethingHere = "hello!";
origemDados2.somethingHere2 = "google";
origemDados2.definition = new ChildClass2() 
{ 
differentString = "Child class 2", 
internalList = List<somethingDifferent>() 
{ 
new anothersomethingDifferent() { Year = 2013, Active = True },
new anothersomethingDifferent() { Year = 2012, Active = False },
};
}

*Data Sample:*

OrigemDados
ID Property1 Property2
1 hi! new string
2 hello! google

ChildTable1
FatherID differentString Name AnotherProperty
1 Child class 1 ABC 1
1 Child class 1 DEF 35

ChildTable1
FatherID differentString Year Active
2 Child class 2 2013 TRUE
2 Child class 2 2012 FALSE


Conclusion: Map child class with multiple itens and a "when 
typeof(definition) is .... then map to tableX, when typeof(definition) is 
.... then map to tableY"

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fluent-nhibernate+unsubscr...@googlegroups.com.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to