NHibernate 2.0: What is the correct EntityMode: POCO, Map or Xml

I am using some NHibernate 1.2 code with NHibernate 2.0 and it gives me a problem with this line:

return (TId) entityMeta.GetIdentifier(entity);

      

it is asked to add EntityMode: POCO, Map or Xml

return (TId) entityMeta.GetIdentifier(entity, EntityMode.Map);

      

But which regime is correct?


Here's the whole method:

public TId GetId<TId>(TEntity entity)
{
    ISessionFactory sessionFactory = NHibernateSessionManager.Instance.GetSessionFactoryFor(assembly);

    if (sessionFactory == null)
    {
        sessionFactory = NHibernateSessionManager.Instance.GetSessionFactoryFor(GetNHibernateConfig());
    }

    IClassMetadata entityMeta = sessionFactory.GetClassMetadata(typeof(TEntity));

    return (TId) entityMeta.GetIdentifier(entity, EntityMode.Map);
}

      

+1


a source to share


1 answer


You need to use EntityMode.POCO, more details can be found on this blog



+2


a source







All Articles