I do a query through nhibernate to get a record back from the database.
var result = session.Query<TableA>().Where(x => x.Id == 10).FirstOrDefault();
result.Where = "hi";
session.Update(result)
session.Commit();
So I get a result back and update a property and try to update and then commit it. This will crash because I have forigen key to Table B(Table A can Has one Table B and Table B has many Table A's)
So this reference cannot be null. So when it tries to do an update it crashes.
So I have to do
var result = session.Query<TableA>().Where(x => x.Id == 10).FirstOrDefault();
result.Where = "hi";
result.TableB = session.Load<TableB>(1);
session.Update(result)
session.Commit();
Then it is happy.
How can I do an update without having to load TableB in?