c# - Serialize DetachedCriteria with nHibernate -
I am trying to serialize a different ceratization so that I can save it in a database and at the same time I can use the criteria again. When I run the code below, I can not be "NHibernate.Criterion.DetachedCriteria" sequentially because there is no parametted constructor in it.
different criteria 1 = separate classification. For safety & gt; Security ("like"). (Add expression ("objectcode", "1234");); XmlSerializer s = New XmlSerializer (Typef (Separated Syrcia)); Text writer author = new stringwriter (); S.Serialize (author, criterion1); Writer.Close (); Is there any good way to serialize a different one?
I have played something like this before. My first thought was that was for different classification sub-class so that you could provide yourself a default constructor, however, to dig through CriteriaImpl class, which is internally classified separately .
By seeing the XmlSerializer, it does not look like this will work if your object does not have any default constructor.
I went to this post, however:
Based on this, it can work (I have not tested it, though):
// Change different caratreset in a byte array MemoryStream ms = new MemoryStream (); IFormatter formatter = new BinaryFormatter (); Formatter.Serialize (MS, different CERTARIA); // byte array Serialize XmlSerializer = New XmlSerializer (type (byte []); Text writer author = new stringwriter (); S.Serialize (author, Ms.Buffer); Writer.Close ();
Comments
Post a Comment