Hi,

I am not sure what you mean by "objects are not initialized (loaded)
when accessing only the Id."
The Id is a virtual property so that seems to contradict your next
line?

I was able to restructure my code to share the session without too
much trouble and everything seems to be working.

  Thanks for the help, Vin

On Aug 25, 1:21 pm, Diego Mijelshon <[email protected]> wrote:
> As José said, objects are not initialized (loaded) when accessing only the
> Id. But they MUST be loaded when calling virtual methods on them.
> You should take advantage of caching.
>
>     Diego
>
> On Wed, Aug 25, 2010 at 07:20, vin <[email protected]> wrote:
> > Unfortunately I am loading the currencies in a different Session.
> > The loads are separate and happen at different times since the
> > currencies are used in many places in the application.
>
> > I was hoping there was a way of simply saying not to load the rest of
> > the object on the Id access since the data for the Id is already
> > loaded and that's all I want.
>
> > From what you are saying it seems like that isn't possible.
>
> > I know I could add a CurrencyId property to the Country and use that
> > instead of the object but that seems like a hack.
>
> > I will see if I can rewrite my code to use a long running Session.
>
> >  Thanks, Vin
>
> > On Aug 24, 7:01 pm, Diego Mijelshon <[email protected]> wrote:
> > > When Equals is overridden, calling it causes proxy initialization.
> > > But if you are loading the currencies in the same session, you don't need
> > to
> > > do that; NHibernate will create only one instance of each Curreny, so
> > > default Equals or even == comparison will work.
>
> > >     Diego
>
> > > On Tue, Aug 24, 2010 at 11:03, vin <[email protected]> wrote:
> > > > Hi,
>
> > > > Here you go.
> > > > Equality is tested by the Equals function below, that is what calls
> > > > the Id property.
>
> > > > On Aug 24, 3:50 pm, José F. Romaniello <[email protected]> wrote:
> > > > > Please show your Currency class and mappings, and aslo show us how do
> > you
> > > > do
> > > > > the equality in currency.
>
> > > > --- Class ---
> > > > public class Currency
> > > > {
> > > >    public virtual string Id { get; set; }
> > > >    public virtual string Name { get; set; }
>
> > > >    public override bool Equals(object obj)
> > > >    {
> > > >        Currency currencyObj = obj as Currency;
>
> > > >        if ((currencyObj != null) && (Id == currencyObj.Id))
> > > >            return true;
>
> > > >        return false;
> > > >    }
> > > > }
>
> > > > --- Mapping ---
> > > > <?xml version="1.0" encoding="utf-8" ?>
> > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> > > >                   assembly="XXX.Data"
> > > >                   namespace="XXX.Data.Domain">
>
> > > >  <class name="Currency">
> > > >    <id name="Id">
> > > >      <column name="CurrencyId" sql-type="nvarchar(3)" not-
> > > > null="true" />
> > > >      <generator class="assigned" />
> > > >    </id>
> > > >    <property name="Name" not-null="true" />
> > > >  </class>
>
> > > > </hibernate-mapping>
>
> > > > --
> > > > 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]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > --
> > 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]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.

-- 
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.

Reply via email to