I finally found the problem about why I was not able to generate a new
table from the dictionary. I did not have the override class as Public, so
it did not work.
*public *class Email_Map : IAutoMappingOverride<Email>
{
public void Override(AutoMapping<Email> mapping)
{
......
Now, the new table is generated as expected (with the 3 attributtes) *but I
have another problem*. when I try to insert an element, the data is saved
in the class email but nothing in the table destinies_persons, so it does
not insert the information of the dictionary.
this is the way I am mapping the dicctionary:
mapping.HasManyToMany(x =>
x.Destiny_Persons ).AsEntityMap().Element("Status", c =>
c.Type<short>()).Not.LazyLoad();
I see that the object in the following method has the dicctionary with data
but this Save only generate the insert in the table Email returning an OK
result.
using (NHibernate.ITransaction tx = NHSession.BeginTransaction())
{
*NHSession.Save((T)pObject);*
tx.Commit();
result.DAO_Error = DAO_Error_Type.OK;
}
Do you see something wrong in my code?
thanks
El miércoles, 24 de agosto de 2016, 14:21:20 (UTC+2), Ivan Ruiz de Eguilaz
Sosoaga escribió:
>
> I have problems generating a new table by using HasManyToMany only When I
> have a IDictonary as a source, for instance If I try it with an IList I do
> not have any problem and I see how a new table is generated and the
> relations. But I need to use a IDictioonary
>
> The example:
>
>
> public class Email: I_CLASS
> {
>
> public virtual int Id { get; set; }
> public virtual IDictionary<Person, short> Destiny_Persons { get; set; }
>
> }
>
> public class Person: I_CLASS
> {
>
> public virtual int Id { get; set; }
>
>
> }
>
> class Notification_DTO_Map : IAutoMappingOverride<Notification_DTO>
> {
> public void Override(AutoMapping<Notification_DTO> mapping)
> {
>
> mapping.HasManyToMany<User_DTO>(x =>
> x.Destiny_Users).Table("Destiny_Persons")
> .ParentKeyColumn("Email")
> .ChildKeyColumn("Person")
> .AsEntityMap().Element("Email_Status", part =>
> part.Type<short>());
> }
>
> }
>
> my target is to have that dictionary and a new table called
> Destiny_Persons with the followinf attributtes:
>
> - Person_Id (int) PK FK
> - Email_Id (int) PK FK
> - Status (short) not null
>
> The status won´t be part of the PK
>
> If a use a IList like this public virtual IList<Person> Destiny_Persons {
> get; set; }
> and in the mapping: mapping.HasManyToMany(x =>
> x.Destiny_Persons ).Table("Destiny_Persons");
> this works without the Status attributte
>
> I have tried a lot of different ways of putting this such as changing the
> order of the elements in the dictionary <short, Person>, using asMap
> instead of AsEntityMap, not using partenkeycolums and child, changing the
> order... and so on
>
> I do not have any error when I generate the database but I am not able to
> generate the table Destiny_Persons when I have a IDictionary as a source
>
> Thanks
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.