How to Serialize a class


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm trying to wrap my head around this serialization thing. I have built (the start of) a replacement (er...ok maybe replacement is a bit strong...) for the BrowseDialog (because it doesn't allow code driven filters, to enable row level security). I'd like to save search configurations, which would just be an instance of a class, which means I need to serialize the class. I have read about this, but I'm not getting it yet. How do you enable serialization of a class? A brief example might help.



Thanks!
Replies
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
So, if I add the Serializable() attribute to a class, then I can indicate that class as a custom data type for a field in a BO and save instances to the db?



If this is right, then I'm assuming the field type in the db would be varbinary(max) in SQL 2005 and image in 2000 right?



Am I correct that if I have referenced classes within this class, and they are also marked as Serializable(), they would also get serialized along with the parent class (and thus also stored)?



It can't be that easy....Blink
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Oh, but it is that easy Smile  Some of .NET is just magic...

Yes, all of the field types within your object will need to be serializable as well.  And unfortunately, you won't be able to tell whether all of the .NET types you're using in fields are serializable until runtime.  You never get any compile-time errors with serialization stuff.

As for the data type, yes, it needs to be either Image or VarBinary(MAX), and then you need to customize the field within the BOMapper and mark it as serializable and set the property type.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search