AR is primarily about mapping the entities. all the querying and
session management is really specific to NHibernate. if you search for
NHibernate best practices, or NHibernate session management this
should get you started.
I believe there is an object in AR ARRepositoryModerator, or something
like that. basically is moves all the base active record functions to
the moderator, rather than having your domain objects inherit it. I
would recommend this approach as it keeps the entities free of the
responsibility to perform CRUD. As for custom queries. I would put
them in separate classes as well. With NH I inherit from
DetachedCriteria. and pass required parameters with ctor args. here is
an example
public class OrdersWithInADateRange : DetachedCriteria
{
public OrdersWithInADateRange(DateTime start, DateTime end) :
base (typeof(Order))
{
Add(Restirctions.Between("OrderDate", start, end));
.SetFetchMode("Lines", FetchMode.Join))
.SetResultTransformer(new
DistinctRootEntityResultTransformer())
}
}
and the usage would look like this
var orders = new OrdersWithInADateRange(start,
end).CreateExecutableCriteria(session).List<Order>();
On Sep 11, 1:03 pm, Chris Sims <[email protected]> wrote:
> I am currently developing a Survey management system for my company. I
> am getting pretty good at creating straightforward classes that
> persist to a database. I do have a couple questions on optimum uses of
> AR.
>
> I have a user security model that has User, Roles and Sessions. When a
> user logs into the system, a new session should be created and
> persisted to the database.
> I have created a support class that actually has a Login method that
> takes a user name/password hash and validates and creates a session
> object. Is it more ideal under the AR model to put that logic into the
> User class itself or keep it in a utility class? Also, The session has
> an "EndSession" method that first checks to see if the Session object
> "IsUnsaved" if it is not "Unsaved" then I update the logoutdate time
> and set the session to inactive then call SaveAndFlush() to update the
> object and return false or true when this is done.
>
> I know there are plenty ways of performing these tasks, what I am
> curious to learn is if this is a good way of doing this?
>
> Also, are there good resources out there that talk about using the AR
> patter within WinForms programs? What types of Interface patterns work
> well with AR and where can I go to learn about them?
>
> Thank you again for your help!
> Chris Sims
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---