I changed the direction of the join so the mapping works Template > Fields. It's not ideal as I have to create additional objects/maps but it results in a similar query being executed and the end result that I'm looking for. Still open for ideas if anyone has them on how to join child > parent.
On Mar 22, 12:59 pm, Colin Bowern <[email protected]> wrote: > I am trying to retrieve the individual detail rows without having to > create an object for the parent. I have a map which joins a parent > table with the detail to achieve this: > > Table("UdfTemplate"); > Id(x => x.Id, "Template_Id"); > Map(x => x.FieldCode, "Field_Code"); > Map(x => x.ClientId, "Client_Id"); > > Join("UdfFields", join => > { > join.KeyColumn("Template_Id"); > > join.Map(x => x.Name, "COLUMN_NAME"); > join.Map(x => x.Label, "DISPLAY_NAME"); > join.Map(x => x.IsRequired, "MANDATORY_FLAG") > .CustomType<YesNoType>(); > join.Map(x => x.MaxLength, "DATA_LENGTH"); > join.Map(x => x.Scale, "DATA_SCALE"); > join.Map(x => x.Precision, "DATA_PRECISION"); > > join.Map(x => x.MinValue, "MIN_VALUE"); > join.Map(x => x.MaxValue, "MAX_VALUE"); > }); > > When I run the query in NH using: > > Session.CreateCriteria(typeof(UserDefinedField)) > .Add(Restrictions.Eq("FieldCode", code)).List<UserDefinedField>(); > > I get back the first row three times as opposed to the three > individual rows it should return. Looking at the SQL trace in NH > Profiler the query appears to be correct. The problem feels like it > is in the mapping but I am unsure how to troubleshoot that process. I > am about to turn on logging to see what I can find but I thought I > would post here in case someone with experience mapping joins knows > where I am going wrong. > > Thanks! > Colin -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
