Thanks for the input, Raul.

What you said makes sense, but as soon as I touch the employee.Department,
it forces the lazy load.  Is there some way I can grab the proxy out of the
employee and avoid the load?

On Thu, Sep 17, 2009 at 1:31 PM, Raul Carlomagno <[email protected]>wrote:

>
> when you fetch an employee, department comes as a proxy, and that
> proxy does have the id property which maps to
> user_table.department_id_field
>
> On Sep 17, 3:25 pm, Doug Swisher <[email protected]> wrote:
> > 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