Monday 15 August 2011

c# - Serializing objects into the database while maintaining flexibility -


The properties of the object will change over time, keeping in mind that what I do to serialize an object in the database Want the approach?

First of all, I thought about ensuring that all my objects apply an interface, but when an interface loses one asset and another takes advantage, what happens is restoring But what about the current serial data in the database?

Should I use intangible classes or interfaces?

Below is a partial implementation that lets you resize flexibility and get some ideas For the management of additional additions and deletions, when you do not add any problems to the properties when you drop the properties, you can not allow to create such new properties in the future, but preserve existing data or All data associated with those properties Let programmed removed.

  /// & lt; Summary & gt; /// Data storage can look something like this // Creating a Table PersistObject (ObjectId Int) /// Create Table PersistProperty (PropertyId int, PropertyName varchar (50)) /// Table data (ValueId int, PropertyId int, SerializedValue Image) /// & lt; / Summary & gt; Interface IFlexiblePersistence {This object [string propertyName] {get; Set;} zero continuous (); } Category Person: IFlexiblePersistence {Language & lt; String, Object & gt; Information; Public person (int interior) {data = popupperson data (person ID); } Public this [string propertyName] object [retrieve {return data [propertyName]; } Set {data [propertyName] = value; To be continued (); }} Public Zero Continuous () {LoopThroughAllValuesAndSaveToDB (); }}  

No comments:

Post a Comment