Bump! anyone with any ideas?

On Mar 1, 1:24 pm, sianabanana <sianm...@hotmail.com> wrote:
> Hi,
>
> I have a One - To - One relationship
>
> Product may have 0 or 1 CustomItem
> CustomItem refrences Product
>
> my database model simplified is
>
> Product table - columns - ProductId, CutomItemId
> Custom Item table - columns - CustomItemid, Additional information
>
> public class Product
>     {
>         public virtual int Id { get; set; }
>         public virtual CustomItem CustomItem { get; set; }
>     }
>
>     public class CustomItem
>     {
>         public virtual int Id { get; set; }
>         public virtual string AdditionalInformation { get; set; }
>         public virtual Product Product { get; set; }
>     }
>
> my overrides (im using auto mapping)
> public class ProductMapOverride : IAutoMappingOverride<Product>
>     {
>         public void Override(AutoMap<Product> map)
>         {
>             map.References(x => x.CustomItem)
>                 .Unique()
>                 .TheColumnNameIs("CustomItemId")
>                 .LazyLoad()
>                 .Cascade.None();
>         }
>     }
>
>     public class CustomItemMapOverride :
> IAutoMappingOverride<CustomItem>
>     {
>         public void Override(AutoMap<CustomItem> map)
>         {
>             map.HasOne(x => x.Product)
>                 .PropertyRef(p => p.CustomItem)
>                 .Cascade.All();
>         }
>     }
>
> When i query my repository calling .Expand("CustomItem")
>
> in my profiler, this is what i see..
> SELECT this_.ProductId                    as ProductId0_1_,
>        this_.CustomItemId                 as CustomIt2_0_1_,
>        customitem2_.CustomItemId          as CustomIt1_1_0_,
>        customitem2_.AdditionalInformation as Addition2_1_0_
> FROM   `Product` this_
>        left outer join `CustomItem` customitem2_
>          on this_.CustomItemId = customitem2_.CustomItemId
>
> this looks good - it has asked for the custom item info
>
> but then i get n+1 of these
> SELECT product0_.ProductId    as ProductId0_0_,
>        product0_.CustomItemId as CustomIt2_0_0_
> FROM   `Product` product0_
> WHERE  product0_.CustomItemId =? p0
>
> can any one shed any light on how i can get rid of this N+1 problem.
> Its driving me crazy

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

Reply via email to