To optimize a bit of code, I'd like to be able to fetch the value of a
foreign key without actually doing the lookup on the foreign table.
The relations are all marked as lazy.  Is this possible?

As an example, I have an employee record that belongs to a department,
as shown below:

    [ActiveRecord(Lazy = true)]
    public class Employee
    {
        [PrimaryKey]
        public virtual Int64 Id { get; set; }

        [Property(Length = 100)]
        public virtual string Name { get; set; }

        [BelongsTo(Lazy = FetchWhen.OnInvoke)]
        public virtual Department Department { get; set; }
    }

When I do a Find and pull an Employee out of the database, I'd like to
be able to pull the ID of the department out of the Employee record
without actually loading the Department.  The following snippet will
work:

    var id = employee.Department.Id;

but that lazy-loads the Department, and I don't want the performance
hit.

I've looked a teeny bit at interceptors and event listeners, but those
seem to be called after I call Save(), which is too late in my case.

Is there a way to do this?

Thanks in advance for any assistance.

Cheers,
-Doug
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to