If I am not wrong, the method ISession.Refresh need to "refresh" (reload or load) an object from the database that the Ids matches with the defined in the object passed by argument. So when I try, for example:
Code:
public class TestA{
private int id;
private string someData;
public int Id {
get { return id; }
set { id = value; }
}
public int Data {
get { return someData; }
set { someData = value; }
}
public TestA()
{}
}
...
void someMethod(ISession session)
{
TestA a = new TestA();
a.Id = 2; // using some object with Id 2 in the database
session.Refresh(a);
/* I expect for the data from the database of the object
that have the Id = 2 to be loaded, but it doens't
*/
Console.WriteLine("Id: {0} Data: {1}", a.Id, a.Data);
/* And if I call the method ISession.Load for example
I will have an error, because it says that the object already
was loaded.
*/
session.Load(a, a.Id); // or a = (TestA) session.Load(typeof(TestA), 2);
}
...
I have used the same code before in version 0.7 and was working. This situation can be reversed when I use ISession.Clear and ISession.Load, but in this way I lost all the objects that already was loaded and
other thing, when I use composite keys I need this method because the method ISession.Load supports only one key value to loaded.