Hi, i'm trying to create a class with several optionally joined tables 
containing extension properties. There are several extension tables because 
they contain some optional, predefined property sets that can be turned on 
or off for some records based on configuration. There's no problem with 
mapping the optional joins, but the trouble begins when I'd like to map all 
these extension columns to a dictionary property in my C# data object. I 
tried using dynamic component for each of joined table mapping, but 
NHIbernate complains that I can't define more than one mapping for the 
dictionary. So, using a dynamic component, I'm able to map at most one 
extension table and I don't see any way to 'fix' that.

Here's my mapping code, hope it explains what i'm trying to achieve

public class UserRequestMap : FluentNHibernate.Mapping.SubclassMap<
UserRequest>
    {
        public UserRequestMap() 
        {
            NLog.LogManager.GetCurrentClassLogger().Warn("Mapping urq");
            DiscriminatorValue(2);
            References(x => x.EndUser).Not.Nullable();
            Join("ext_UserRequest_1", jm => {
                     jm.Optional();
                     jm.DynamicComponent(x => x.DynamicFields, dm => {
                                         dm.Map<decimal>("amount");
                                         dm.Map<int>("size");
                                         dm.Map<string>("item_name").
Nullable();
                                     });
                 });
            Join("ext_UserRequest_2", jm => {
                     jm.Optional();
                     jm.DynamicComponent(x => x.DynamicFields, dm => {
                                             dm.Map<int>("service_number");
                                             dm.Map<DateTime>("order_date"
).Not.Nullable();
                                             dm.Map<string>("service_codes"
).Nullable();
                                         });
                 });


So, I have a 'UserRequest' table that optionally can join to 
'ext_UserRequest_1' and 'ext_UserRequest_2' tables.
The 'ext_UserRequest_1' table contains 3 columns: 'amount', 'size' and 
'item_name' (plus a key column with UserRequest ID), and the 
'ext_UserRequest_2' contains service_number, order_date and service_codes 
columns.
As you see, all these additional column names are unique so they could be 
mapped to same dictionary without confusion. But for some reason NHibernate 
will allow only the first table to be mapped.
Could you suggest something? I want to be able to map these extension 
tables dynamically, without modifying C# object structure.

Thanks
R

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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 http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to