Yes, it worked thank you for all your help, I ended up creating my own
static methods in inherited base classes so I can share the
functionality throughout the project, perhaps this isn't any cleaner,
but it makes me FEEL better :D
public static T[] FindAll(bool cacheable)
{
if (!cacheable)
return FindAll();
else
return FindAll(DetachedCriteria.For<T>()
.SetCacheable(cacheable));
}
public static T[] FindAll(Order order, bool cacheable)
{
return FindAll(DetachedCriteria.For<T>()
.SetCacheable(cacheable)
.AddOrder(order));
}
public static T[] FindAll(Order[] orders, bool cacheable)
{
return FindAll(DetachedCriteria.For<T>()
.SetCacheable(cacheable),orders);
}
On Feb 4, 8:20 pm, Daniel Pupek <
d...@agilejedi.com> wrote:
> You'll use the detached criterion a lot. Don't worry if the criterion syntax
> seems a bit odd. You'll pick it up fast. For SQL junkies HQL tends to go
> down a bit easier...I hear that hql exhibits a little better performance but
> we haven't noticed a difference.
> A couple notes though, you can't resuse a DetachedCriteria once it has been
> passed to activerecord. You can call .Clone though to get a replica of it.
> Don't try to over optimize things on your own by using the session or static
> properties. You just end up stepping on top of what Nhibernate is doing for
> you. Nhibernate and active record have some interest ways to control the
> caching...you just have to play with it a bit and in the long run you'll be
> a lot happier.
>
> Don't worry about opening and closing sessions....ActiveRecord does a fair
> bit of the session handling for you. You'll just end up creating a bunch of
> Stack Overflows. If you have a non-trivial situation and believe you need to
> circumvent the automatic session scopes then place your code inside of a
> using statement:
>
> using(new SessionScope())
> {
>
> Do some active record stuff here!
>
> }
>
> ActiveRecord will generally try to use the last sessionscope opened...the
> using statement ensures it is disposed properly.
>
> Dan
>