1. It is problematic to compare DateTime values when using DateTime.Now to set the value because Ms Sql Server can NOT store dates with the same accuracy as the DateTime struct can - so it is possible to store a DateTime and not retrieve the exact same DateTime.
2. We can't compare the blogItem.ParentBlog and item.ParentBlog because they will be differnt objects since they were loaded in "different sessions". If Blog implemented Equals() and GetHashCode() correctly then we could compare them - they would be equal by object equality - blog.Equals(otherBlog), but not have by object identity - blog==Otherblog - because they would be seperate objects in memory. NHibernate guarantees the same object by identity inside of a Session only.
3. The only way to make sure these are referring to the same blog is by checking for database identity equality - ie: comparing there property "Id" because that is the property used as the primary keys.
沒有留言:
張貼留言