Hmm.. my intentions was to achieve something to the effect of this in
SQL, so as to retrieve all items in a single trip.
select blog.*, post.*
from Blogs blog
left outer join Posts post on blog.BlogID = post.BlogID
and post.PostDate = (select max
(latestPost.PostDate) as latestDate
from Post latestPost where latestPost.BlogId = blog.BlogID)
where blog.ID = @blogid
---------
I'll give your suggestions a try thou.
Thanks.
On Dec 6, 6:40 am, cws <[email protected]> wrote:
> Hi!
>
> I think it is that Fetch.Join() should be Fetch.Lazy() or not
> specified becasue it defaults to lazy.
> When using Fetchmode join the batchsize will have no affect.
>
> On Dec 3, 8:02 am, KnaveT <[email protected]> wrote:
>
> > 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.