I’m trying to learn Fluent-NHibernate with tutorial I found on its site: https://github.com/jagregory/fluent-nhibernate/wiki/Getting-started
In this code you can see reference to Store object:
public class Employee
{
public virtual int Id { get; private set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual Store Store { get; set; }//<-- here
}
public class Store
{
public virtual int Id { get; private set; }
public virtual string Name { get; set; }
public virtual IList<Product> Products { get; set; }
public virtual IList<Employee> Staff { get; set; }
}
Lets say I will have 10000 of Employees(or more) and each will have reference to store instance. What will happen if we have only one store and many references to it. Will each element store only reference to memory of store object, or will all of them store individual object resulting in huge memory taken away ?
It depends on how you’re using ISession. Inside single ISession you’ll get only one instance of
Store. Different ISessions will have different instances ofStore.