I am using NHibernate v2.1.0 and FluentNHibernate v1.0 in my project
and here's my sample scenario.


public class Blog
{
   public virtual int Id {get;set;}

   public virtual Post LatestPost
   {
      get{ return this.LatestPosts.First(); }
   }

   public virtual ICollection<Post> LatestPosts {get;set;}
   public virtual IList<Post> Posts {get;set;}
}

public class Post
{
   public virtual int Id {get;set;}
   public virtual Blog Blog { get;set; }
}
//------------------

My fluent Mapping is:

public class BlogMap : ClassMap<Blog>
{
   public BlogMap()
   {
      LazyLoad();

      HasMany( x=> x.LatestPosts )
          .KeyColumn ( "PostID")
          .AsSet()          // <- Also tried AsBag() with no luck.
          .Fetch.Join()
          .Cascade.None()
          .OrderBy ("PostDate DESC")
          .BatchSize(1); // <---- set batchsize...

      HasMany( x=> x.Posts )
          .KeyColumn ( "PostID")
          .AsBag()
          .Fetch.Select()
          .LazyLoad()
          .Inverse()
          .Cascade.None();
   }
}

//================================================

Now, when I call blog.LatestPost, the profiler actually shows that
batchsize (of 1 in this case), is never implemented.

I've tried with hbm mapping files and its the same, so I rule out a
problem with FluentHibernate.

On a side note, how would you gurus here implement for such a
scenario?

Thanks.

Knave T



--

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.


Reply via email to