Note that there are some explanatory texts on larger screens.

plurals
  1. PO.Net Serialization, XmlDataReader, a SQL Database and the FlagsAttribute!
    primarykey
    data
    text
    <p>Giving a quick overview of my situation:</p> <p>I am working on an N-Tier app that relies a lot on serialization, objects interact with the database mainly in a serialized fashion, objects and collections are inserted, updated and read as XML from within stored procedures.</p> <p>For some of the smaller data classes I am simply using ExecuteNonQuery, Reader, etc to interact with the data, as its easier, but I have encountered a problem.</p> <p>Data is inserted into the database using ExecuteNonQuery, using Parameters - some of the data inserted are properties that are Enums (stored in the DB as ints) that have the FlagAttribute attached. On a Enum such as:</p> <pre><code>&lt;Flags()&gt; _ Public Enum Fruit As Integer &lt;Description("None"), XmlEnum("0")&gt; None = 0 &lt;Description("Apple"), XmlEnum("1")&gt; Apple = 1 &lt;Description("Banana"), XmlEnum("2")&gt; Banana = 2 &lt;Description("Orange"), XmlEnum("4")&gt; Orange = 4 End Enum </code></pre> <p>The value read back might be an Integer value of 1, 3, 7, etc, and inserted into the database not using serialization, when it is read back however as part of a larger group of classes using the ExecuteXmlReader (filling a XmlReader object) and then needing to be deserialized, it can not be, as 7 for example, causes 'Instance validation error: '7' is not a valid value for Fruit', as it is expecting it to be serialized in the format of:</p> <pre><code>&lt;fruitOptions&gt;1 2 4&lt;fruitOptions&gt; </code></pre> <p>All in all it is a little confusing, and I could probably work around it by storing it in the database in the 1, 2, 4 format, but sadly not in the int type that it currently is in.</p> <p>Does anyone have any ideas on this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload