问题
I am looking for a solution to persist NHibernate DetachedCriteria objects to a database. I have tracked down the NHibernateUtil and the GetSerializable method, but I'm unsure how to use it to serialize a DetachedCriteria object. Any help on this would be greatly appreciated. Thank you.
回答1:
DetachedCriteria is serializable and because it is not connected to a session, it should be doable by just doing regular .net object serialization as described here:
http://msdn.microsoft.com/en-us/library/ms973893.aspx
If serialized to a binary format it could be persisted as byte-array to a binary blob field (NHibernateUtil.BinaryBlob.SqlType).
来源:https://stackoverflow.com/questions/1245985/how-do-i-serialize-an-nhibernate-detachedcriteria-object