XMLSerializer and SqlParameter in .NET 2.0 vs .NET 1.1

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have the following problem.
I have a .NET 1.1 based software that relies heavily on SqlParameters and
also on storing them in config-files which I create using XmlSerializer.
In .NET 2.0 I do not seem to be able to serialize SqlParameter the same way
I could do it in .NET 1.1. Also .NET 2.0 seems to change the SqlDbType of the
SqlParameter if I assign a value.


Example (working in 1.1):
SqlParameter oSqlParameter;
oSqlParameter=new SqlParameter();
oSqlParameter.ParameterName="@MaxTries";
oSqlParameter.Size=8;
oSqlParameter.SqlDbType=SqlDbType.BigInt;
oSqlParameter.Value = 10;

then (of course I assign oSqlParameter to obj first):
XmlSerializer MySerializer = new XmlSerializer(obj.GetType());
TextWriter myTextWriter = new StreamWriter(filename);
MySerializer.Serialize(myTextWriter, obj);
myTextWriter.Close();

results in:
<?xml version="1.0" encoding="utf-8"?>
<SqlParameter xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DbType>Int64</DbType>
<SqlDbType>BigInt</SqlDbType>
<ParameterName>@MaxTries</ParameterName>
<Size>8</Size>
<Value xsi:type="xsd:int">10</Value>
</SqlParameter>

..NET 2.0:
The above code results in:
"System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: The type
System.Data.SqlTypes.SqlInt32 may not be used in this context. To use
System.Data.SqlTypes.SqlInt32 as a parameter, return type, or member of a
class or struct, the parameter, return type, or member must be declared as
type System.Data.SqlTypes.SqlInt32 (it cannot be object). Objects of type
System.Data.SqlTypes.SqlInt32 may not be used in un-typed collections, such
as ArrayLists.\r\n at
System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String
name, String ns, Object o, Boolean xsiType)\r\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write1_Object(String
n, String ns, Object o, Boolean isNullable, Boolean needType)\r\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write9_SqlParameter(String
n, String ns, SqlParameter o, Boolean isNullable, Boolean needType)\r\n at
Microsoft.Xml.S
erialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write10_SqlParameter(Object
o)\r\n --- End of inner exception stack trace ---\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object
o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)\r\n
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
Object o)\r\n at
DPWN.DPWNConfigTools.ConfigXmlHelper.SerializeToFile(String filename, Object
obj) in D:\\SOURCE\\ConfigXmlHelper.cs:line 43"

(Notice that it says SqlInt32, implying that it takes the datatype for the
value "10").

I substitute the oSqlParameter assignment like this:
oSqlParameter=new SqlParameter();
oSqlParameter.ParameterName="@MaxTries";
oSqlParameter.Size=8;
oSqlParameter.SqlDbType=SqlDbType.BigInt;
oSqlParameter.Value=Convert.ToInt64( 10);
and the result is:
System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: The type
System.Data.SqlTypes.SqlInt64 may not be used in this context. To use
System.Data.SqlTypes.SqlInt64 as a parameter, return type, or member of a
class or struct, the parameter, return type, or member must be declared as
type System.Data.SqlTypes.SqlInt64 (it cannot be object). Objects of type
System.Data.SqlTypes.SqlInt64 may not be used in un-typed collections, such
as ArrayLists.\r\n at
System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String
name, String ns, Object o, Boolean xsiType)\r\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write1_Object(String
n, String ns, Object o, Boolean isNullable, Boolean needType)\r\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write9_SqlParameter(String
n, String ns, SqlParameter o, Boolean isNullable, Boolean needType)\r\n at
Microsoft.Xml.S
erialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write10_SqlParameter(Object
o)\r\n --- End of inner exception stack trace ---\r\n at
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object
o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)\r\n
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter,
Object o)\r\n at
DPWN.DPWNConfigTools.ConfigXmlHelper.SerializeToFile(String filename, Object
obj) in D:\\SOURCE\\ConfigXmlHelper.cs:line 43

(Notice that now it complains about SqlInt64)

My main problem is however the exception at all.
What is the best way to (Xml)serialize a SqlParameter in .NET 2.0 ?

I am aware that SqlParameter does not explicitly say that it implements
IXmlSerializable and/or ISerializable
however, it worked like a charm in .NET 1.1

Anybody has a solution that allows me to maintain SqlParameter-Serialization
in .NET 2.0?

(Was I just "lucky" in .NET 1.1 that I was able to Serialize/Deserialize an
SqlParameter?)


Regards,

Andi
 
Hi,

Currently I am researching the issue and we will reply here with more
information as soon as possible.
If you have any more concerns on it, please feel free to post here.

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi,

additional information: the stacktrace of the InnerException is:

" at
System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String
name, String ns, Object o, Boolean xsiType)\r\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write1_Object(String
n, String ns, Object o, Boolean isNullable, Boolean needType)\r\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write9_SqlParameter(String
n, String ns, SqlParameter o, Boolean isNullable, Boolean needType)\r\n at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSqlParameter.Write10_SqlParameter(Object o)"

Take care,
Andi
 
More additional information:

I used "sgen.exe" used the generated XmlSerializer directly and came to the
point when the actual value of the SqlParameter should get serialized as
SqlValue:
This is done in the last "else" part of the generated Serializer:
void Write1_Object(string n, string ns, global::System.Object o, bool
isNullable, bool needType)
in my case
" Writer.WriteEndElement();
return;
}
else {
WriteTypedPrimitive(n, ns, o, true);
return;
}
}
WriteStartElement(n, ns, o, false, null);
WriteEndElement(o);
}"

the parameters are set as the following:
n "SqlValue" string
ns "" string
+ o {10} object {System.Data.SqlTypes.SqlInt32}
(the type information is of course expandable)

So, what is the failure? the XmlSerializer/ sgen.exe mechanism to map
SqlInt32 to a "WriteTypedPrimitive(n, ns, o, true);" call or is it a bug in
WriteTypedPrimitive?
Is SqlInt32 a "TypedPrimitive" in the sense of "simple XML Schema data" or
should it be a complex type?


//
// Summary:
// Writes an XML element whose text body is a value of a simple
XML Schema data
// type.
//
// Parameters:
// name:
// The local name of the element to write.
//
// o:
// The object to be serialized in the element body.
//
// ns:
// The namespace of the element to write.
//
// xsiType:
// true if the XML element explicitly specifies the text value's
type using
// the xsi:type attribute; otherwise, false.
protected void WriteTypedPrimitive(string name, string ns, object o,
bool xsiType);
 
And even more information:
I checked what a XmlSerializer for SqlInt32 would look like (see end of this
post):

So the problem seems to be in my opinion that for SqlParameter the
sgen.exe/XmlSerializer should use something like below for the mentioned
datatype (or for SqlInt64 as another example) but in fact does not do that.
System.Data.SqlTypes.SqlInt32 is XmlSerializable.

Now it would be interesting to have a look at the XmlSerializer generated
for SqlParameter by framework 1.1, however there is no sgen.exe, so it would
mean intercepting the generated temporary .cs files before the framework can
delete them.


XmlSerializer for SqlInt32:
#if _DYNAMIC_XMLSERIALIZER_COMPILATION
[assembly:System.Security.AllowPartiallyTrustedCallers()]
[assembly:System.Security.SecurityTransparent()]
#endif
[assembly:System.Reflection.AssemblyVersionAttribute("2.0.0.0")]
[assembly:System.Xml.Serialization.XmlSerializerVersionAttribute(ParentAssemblyId=@"70bbeca7-72bc-4c00-862b-642b5f48a565,", Version=@"2.0.0.0")]
namespace Microsoft.Xml.Serialization.GeneratedAssembly {

public class XmlSerializationWriterSqlInt32 :
System.Xml.Serialization.XmlSerializationWriter {

public void Write1_int(object o) {
WriteStartDocument();
if (o == null) {
WriteEmptyTag(@"int", @"");
return;
}

WriteSerializable((System.Xml.Serialization.IXmlSerializable)((global::System.Data.SqlTypes.SqlInt32)o), @"int", @"", false, true);
}

protected override void InitCallbacks() {
}
}

public class XmlSerializationReaderSqlInt32 :
System.Xml.Serialization.XmlSerializationReader {

public object Read1_int() {
object o = null;
Reader.MoveToContent();
if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
if (((object) Reader.LocalName == (object)id1_int &&
(object) Reader.NamespaceURI == (object)id2_Item)) {
o =
(global::System.Data.SqlTypes.SqlInt32)ReadSerializable((
System.Xml.Serialization.IXmlSerializable)System.Activator.CreateInstance(typeof(global::System.Data.SqlTypes.SqlInt32),
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.CreateInstance |
System.Reflection.BindingFlags.NonPublic, null, new object[0], null));
}
else {
throw CreateUnknownNodeException();
}
}
else {
UnknownNode(null, @":int");
}
return (object)o;
}

protected override void InitCallbacks() {
}

string id2_Item;
string id1_int;

protected override void InitIDs() {
id2_Item = Reader.NameTable.Add(@"");
id1_int = Reader.NameTable.Add(@"int");
}
}

public abstract class XmlSerializer1 :
System.Xml.Serialization.XmlSerializer {
protected override System.Xml.Serialization.XmlSerializationReader
CreateReader() {
return new XmlSerializationReaderSqlInt32();
}
protected override System.Xml.Serialization.XmlSerializationWriter
CreateWriter() {
return new XmlSerializationWriterSqlInt32();
}
}

public sealed class SqlInt32Serializer : XmlSerializer1 {

public override System.Boolean CanDeserialize(System.Xml.XmlReader
xmlReader) {
return xmlReader.IsStartElement(@"int", @"");
}

protected override void Serialize(object objectToSerialize,
System.Xml.Serialization.XmlSerializationWriter writer) {

((XmlSerializationWriterSqlInt32)writer).Write1_int(objectToSerialize);
}

protected override object
Deserialize(System.Xml.Serialization.XmlSerializationReader reader) {
return ((XmlSerializationReaderSqlInt32)reader).Read1_int();
}
}

public class XmlSerializerContract :
global::System.Xml.Serialization.XmlSerializerImplementation {
public override
global::System.Xml.Serialization.XmlSerializationReader Reader { get { return
new XmlSerializationReaderSqlInt32(); } }
public override
global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return
new XmlSerializationWriterSqlInt32(); } }
System.Collections.Hashtable readMethods = null;
public override System.Collections.Hashtable ReadMethods {
get {
if (readMethods == null) {
System.Collections.Hashtable _tmp = new
System.Collections.Hashtable();
_tmp[@"System.Data.SqlTypes.SqlInt32::"] = @"Read1_int";
if (readMethods == null) readMethods = _tmp;
}
return readMethods;
}
}
System.Collections.Hashtable writeMethods = null;
public override System.Collections.Hashtable WriteMethods {
get {
if (writeMethods == null) {
System.Collections.Hashtable _tmp = new
System.Collections.Hashtable();
_tmp[@"System.Data.SqlTypes.SqlInt32::"] = @"Write1_int";
if (writeMethods == null) writeMethods = _tmp;
}
return writeMethods;
}
}
System.Collections.Hashtable typedSerializers = null;
public override System.Collections.Hashtable TypedSerializers {
get {
if (typedSerializers == null) {
System.Collections.Hashtable _tmp = new
System.Collections.Hashtable();
_tmp.Add(@"System.Data.SqlTypes.SqlInt32::", new
SqlInt32Serializer());
if (typedSerializers == null) typedSerializers = _tmp;
}
return typedSerializers;
}
}
public override System.Boolean CanSerialize(System.Type type) {
if (type == typeof(global::System.Data.SqlTypes.SqlInt32))
return true;
return false;
}
public override System.Xml.Serialization.XmlSerializer
GetSerializer(System.Type type) {
if (type == typeof(global::System.Data.SqlTypes.SqlInt32))
return new SqlInt32Serializer();
return null;
}
}
}
 
Unfortunately I cannot post the SqlParameter-XmlSerializers of .NET 2.0 since
the web-based client only allows me a post size of 30000 characters:


..NET 1.1:
[assembly:System.Security.AllowPartiallyTrustedCallers()]
namespace Microsoft.Xml.Serialization.GeneratedAssembly {

public class XmlSerializationWriter1 :
System.Xml.Serialization.XmlSerializationWriter {

void Write1_SqlParameter(string n, string ns,
System.Data.SqlClient.SqlParameter o, bool isNullable, bool needType) {
if ((object)o == null) {
if (isNullable) WriteNullTagLiteral(n, ns);
return;
}
if (!needType) {
System.Type t = o.GetType();
if (t == typeof(System.Data.SqlClient.SqlParameter))
;
else {
throw CreateUnknownTypeException(o);
}
}
WriteStartElement(n, ns, o);
if (needType) WriteXsiType(@"SqlParameter", @"");
WriteElementString(@"DbType", @"",
Write4_DbType(((System.Data.DbType)o.@DbType)));
if (((System.Data.SqlDbType)o.@SqlDbType) !=
System.Data.SqlDbType.@NVarChar) {
WriteElementString(@"SqlDbType", @"",
Write5_SqlDbType(((System.Data.SqlDbType)o.@SqlDbType)));
}
if (((System.Data.ParameterDirection)o.@Direction) !=
System.Data.ParameterDirection.@Input) {
WriteElementString(@"Direction", @"",
Write6_ParameterDirection(((System.Data.ParameterDirection)o.@Direction)));
}
if (((System.Boolean)o.@IsNullable) != false) {
WriteElementStringRaw(@"IsNullable", @"",
System.Xml.XmlConvert.ToString((System.Boolean)((System.Boolean)o.@IsNullable)));
}
if (((System.Int32)o.@Offset) != 0) {
WriteElementStringRaw(@"Offset", @"",
System.Xml.XmlConvert.ToString((System.Int32)((System.Int32)o.@Offset)));
}
if (((System.String)o.@ParameterName) != @"") {
WriteElementString(@"ParameterName", @"",
((System.String)o.@ParameterName));
}
if (((System.Byte)o.@Precision) != (System.Byte)(0)) {
WriteElementStringRaw(@"Precision", @"",
System.Xml.XmlConvert.ToString((System.Byte)((System.Byte)o.@Precision)));
}
if (((System.Byte)o.@Scale) != (System.Byte)(0)) {
WriteElementStringRaw(@"Scale", @"",
System.Xml.XmlConvert.ToString((System.Byte)((System.Byte)o.@Scale)));
}
if (((System.Int32)o.@Size) != 0) {
WriteElementStringRaw(@"Size", @"",
System.Xml.XmlConvert.ToString((System.Int32)((System.Int32)o.@Size)));
}
if (((System.String)o.@SourceColumn) != @"") {
WriteElementString(@"SourceColumn", @"",
((System.String)o.@SourceColumn));
}
if (((System.Data.DataRowVersion)o.@SourceVersion) !=
System.Data.DataRowVersion.@Current) {
WriteElementString(@"SourceVersion", @"",
Write7_DataRowVersion(((System.Data.DataRowVersion)o.@SourceVersion)));
}
Write3_Object(@"Value", @"", ((System.Object)o.@Value), false,
false);
WriteEndElement(o);
}

void Write2_MarshalByRefObject(string n, string ns,
System.MarshalByRefObject o, bool isNullable, bool needType) {
if ((object)o == null) {
if (isNullable) WriteNullTagLiteral(n, ns);
return;
}
if (!needType) {
System.Type t = o.GetType();
if (t == typeof(System.MarshalByRefObject))
;
else if (t == typeof(System.Data.SqlClient.SqlParameter)) {
Write1_SqlParameter(n, ns,
(System.Data.SqlClient.SqlParameter)o, isNullable, true);
return;
}
else {
throw CreateUnknownTypeException(o);
}
}
}

void Write3_Object(string n, string ns, System.Object o, bool
isNullable, bool needType) {
if ((object)o == null) {
if (isNullable) WriteNullTagLiteral(n, ns);
return;
}
if (!needType) {
System.Type t = o.GetType();
if (t == typeof(System.Object))
;
else if (t == typeof(System.MarshalByRefObject)) {
Write2_MarshalByRefObject(n, ns,
(System.MarshalByRefObject)o, isNullable, true);
return;
}
else if (t == typeof(System.Data.SqlClient.SqlParameter)) {
Write1_SqlParameter(n, ns,
(System.Data.SqlClient.SqlParameter)o, isNullable, true);
return;
}
else if (t == typeof(System.Data.DbType)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"DbType", @"");
Writer.WriteString(Write4_DbType((System.Data.DbType)o));
Writer.WriteEndElement();
return;
}
else if (t == typeof(System.Data.SqlDbType)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"SqlDbType", @"");

Writer.WriteString(Write5_SqlDbType((System.Data.SqlDbType)o));
Writer.WriteEndElement();
return;
}
else if (t == typeof(System.Data.ParameterDirection)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"ParameterDirection", @"");

Writer.WriteString(Write6_ParameterDirection((System.Data.ParameterDirection)o));
Writer.WriteEndElement();
return;
}
else if (t == typeof(System.Data.DataRowVersion)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"DataRowVersion", @"");

Writer.WriteString(Write7_DataRowVersion((System.Data.DataRowVersion)o));
Writer.WriteEndElement();
return;
}
else {
WriteTypedPrimitive(n, ns, o, true);
return;
}
}
WriteStartElement(n, ns, o);
WriteEndElement(o);
}

string Write4_DbType(System.Data.DbType v) {
string s = null;
switch (v) {
case System.Data.DbType.@AnsiString: s = @"AnsiString"; break;
case System.Data.DbType.@Binary: s = @"Binary"; break;
case System.Data.DbType.@Byte: s = @"Byte"; break;
case System.Data.DbType.@Boolean: s = @"Boolean"; break;
case System.Data.DbType.@Currency: s = @"Currency"; break;
case System.Data.DbType.@Date: s = @"Date"; break;
case System.Data.DbType.@DateTime: s = @"DateTime"; break;
case System.Data.DbType.@Decimal: s = @"Decimal"; break;
case System.Data.DbType.@Double: s = @"Double"; break;
case System.Data.DbType.@Guid: s = @"Guid"; break;
case System.Data.DbType.@Int16: s = @"Int16"; break;
case System.Data.DbType.@Int32: s = @"Int32"; break;
case System.Data.DbType.@Int64: s = @"Int64"; break;
case System.Data.DbType.@Object: s = @"Object"; break;
case System.Data.DbType.@SByte: s = @"SByte"; break;
case System.Data.DbType.@Single: s = @"Single"; break;
case System.Data.DbType.@String: s = @"String"; break;
case System.Data.DbType.@Time: s = @"Time"; break;
case System.Data.DbType.@UInt16: s = @"UInt16"; break;
case System.Data.DbType.@UInt32: s = @"UInt32"; break;
case System.Data.DbType.@UInt64: s = @"UInt64"; break;
case System.Data.DbType.@VarNumeric: s = @"VarNumeric"; break;
case System.Data.DbType.@AnsiStringFixedLength: s =
@"AnsiStringFixedLength"; break;
case System.Data.DbType.@StringFixedLength: s =
@"StringFixedLength"; break;
default: s = ((System.Int64)v).ToString(); break;
}
return s;
}

string Write5_SqlDbType(System.Data.SqlDbType v) {
string s = null;
switch (v) {
case System.Data.SqlDbType.@BigInt: s = @"BigInt"; break;
case System.Data.SqlDbType.@Binary: s = @"Binary"; break;
case System.Data.SqlDbType.@Bit: s = @"Bit"; break;
case System.Data.SqlDbType.@Char: s = @"Char"; break;
case System.Data.SqlDbType.@DateTime: s = @"DateTime"; break;
case System.Data.SqlDbType.@Decimal: s = @"Decimal"; break;
case System.Data.SqlDbType.@Float: s = @"Float"; break;
case System.Data.SqlDbType.@Image: s = @"Image"; break;
case System.Data.SqlDbType.@Int: s = @"Int"; break;
case System.Data.SqlDbType.@Money: s = @"Money"; break;
case System.Data.SqlDbType.@NChar: s = @"NChar"; break;
case System.Data.SqlDbType.@NText: s = @"NText"; break;
case System.Data.SqlDbType.@NVarChar: s = @"NVarChar"; break;
case System.Data.SqlDbType.@Real: s = @"Real"; break;
case System.Data.SqlDbType.@UniqueIdentifier: s =
@"UniqueIdentifier"; break;
case System.Data.SqlDbType.@SmallDateTime: s =
@"SmallDateTime"; break;
case System.Data.SqlDbType.@SmallInt: s = @"SmallInt"; break;
case System.Data.SqlDbType.@SmallMoney: s = @"SmallMoney";
break;
case System.Data.SqlDbType.@Text: s = @"Text"; break;
case System.Data.SqlDbType.@Timestamp: s = @"Timestamp";
break;
case System.Data.SqlDbType.@TinyInt: s = @"TinyInt"; break;
case System.Data.SqlDbType.@VarBinary: s = @"VarBinary";
break;
case System.Data.SqlDbType.@VarChar: s = @"VarChar"; break;
case System.Data.SqlDbType.@Variant: s = @"Variant"; break;
default: s = ((System.Int64)v).ToString(); break;
}
return s;
}

string Write6_ParameterDirection(System.Data.ParameterDirection v) {
string s = null;
switch (v) {
case System.Data.ParameterDirection.@Input: s = @"Input";
break;
case System.Data.ParameterDirection.@Output: s = @"Output";
break;
case System.Data.ParameterDirection.@InputOutput: s =
@"InputOutput"; break;
case System.Data.ParameterDirection.@ReturnValue: s =
@"ReturnValue"; break;
default: s = ((System.Int64)v).ToString(); break;
}
return s;
}

string Write7_DataRowVersion(System.Data.DataRowVersion v) {
string s = null;
switch (v) {
case System.Data.DataRowVersion.@Original: s = @"Original";
break;
case System.Data.DataRowVersion.@Current: s = @"Current";
break;
case System.Data.DataRowVersion.@Proposed: s = @"Proposed";
break;
case System.Data.DataRowVersion.@Default: s = @"Default";
break;
default: s = ((System.Int64)v).ToString(); break;
}
return s;
}

protected override void InitCallbacks() {
}

public void Write8_SqlParameter(object o) {
WriteStartDocument();
if (o == null) {
WriteNullTagLiteral(@"SqlParameter", @"");
return;
}
TopLevelElement();
Write1_SqlParameter(@"SqlParameter", @"",
((System.Data.SqlClient.SqlParameter)o), true, false);
}
}

public class XmlSerializationReader1 :
System.Xml.Serialization.XmlSerializationReader {

System.Data.SqlClient.SqlParameter Read1_SqlParameter(bool
isNullable, bool checkType) {
if (isNullable && ReadNull()) return null;
if (checkType) {
System.Xml.XmlQualifiedName t = GetXsiType();
if (t == null || ((object)
((System.Xml.XmlQualifiedName)t).Name == (object)id1_SqlParameter && (object)
((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item))
;
else
throw
CreateUnknownTypeException((System.Xml.XmlQualifiedName)t);
}
System.Data.SqlClient.SqlParameter o = new
System.Data.SqlClient.SqlParameter();
bool[] paramsRead = new bool[12];
while (Reader.MoveToNextAttribute()) {
if (!IsXmlnsAttribute(Reader.Name)) {
UnknownNode((object)o);
}
}
Reader.MoveToElement();
if (Reader.IsEmptyElement) {
Reader.Skip();
return o;
}
Reader.ReadStartElement();
Reader.MoveToContent();
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) {
if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
if (!paramsRead[0] && ((object) Reader.LocalName ==
(object)id3_DbType && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@DbType = Read4_DbType(Reader.ReadElementString());
paramsRead[0] = true;
}
else if (!paramsRead[1] && ((object) Reader.LocalName ==
(object)id4_SqlDbType && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@SqlDbType =
Read5_SqlDbType(Reader.ReadElementString());
paramsRead[1] = true;
}
else if (!paramsRead[2] && ((object) Reader.LocalName ==
(object)id5_Direction && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@Direction =
Read6_ParameterDirection(Reader.ReadElementString());
paramsRead[2] = true;
}
else if (!paramsRead[3] && ((object) Reader.LocalName ==
(object)id6_IsNullable && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@IsNullable =
System.Xml.XmlConvert.ToBoolean(Reader.ReadElementString());
paramsRead[3] = true;
}
else if (!paramsRead[4] && ((object) Reader.LocalName ==
(object)id7_Offset && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@Offset =
System.Xml.XmlConvert.ToInt32(Reader.ReadElementString());
paramsRead[4] = true;
}
else if (!paramsRead[5] && ((object) Reader.LocalName ==
(object)id8_ParameterName && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
o.@ParameterName = Reader.ReadElementString();
paramsRead[5] = true;
}
else if (!paramsRead[6] && ((object) Reader.LocalName ==
(object)id9_Precision && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@Precision =
System.Xml.XmlConvert.ToByte(Reader.ReadElementString());
paramsRead[6] = true;
}
else if (!paramsRead[7] && ((object) Reader.LocalName ==
(object)id10_Scale && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@Scale =
System.Xml.XmlConvert.ToByte(Reader.ReadElementString());
paramsRead[7] = true;
}
else if (!paramsRead[8] && ((object) Reader.LocalName ==
(object)id11_Size && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@Size =
System.Xml.XmlConvert.ToInt32(Reader.ReadElementString());
paramsRead[8] = true;
}
else if (!paramsRead[9] && ((object) Reader.LocalName ==
(object)id12_SourceColumn && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
o.@SourceColumn = Reader.ReadElementString();
paramsRead[9] = true;
}
else if (!paramsRead[10] && ((object) Reader.LocalName
== (object)id13_SourceVersion && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
o.@SourceVersion =
Read7_DataRowVersion(Reader.ReadElementString());
paramsRead[10] = true;
}
else if (!paramsRead[11] && ((object) Reader.LocalName
== (object)id14_Value && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@Value = Read3_Object(false, true);
paramsRead[11] = true;
}
else {
UnknownNode((object)o);
}
}
else {
UnknownNode((object)o);
}
Reader.MoveToContent();
}
ReadEndElement();
return o;
}

System.MarshalByRefObject Read2_MarshalByRefObject(bool isNullable,
bool checkType) {
if (isNullable && ReadNull()) return null;
if (checkType) {
System.Xml.XmlQualifiedName t = GetXsiType();
if (t == null || ((object)
((System.Xml.XmlQualifiedName)t).Name == (object)id15_MarshalByRefObject &&
(object) ((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item))
;
else if (((object) ((System.Xml.XmlQualifiedName)t).Name ==
(object)id1_SqlParameter && (object)
((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item))
return Read1_SqlParameter(isNullable, false);
else
throw
CreateUnknownTypeException((System.Xml.XmlQualifiedName)t);
}
throw CreateAbstractTypeException(@"MarshalByRefObject", @"");
}

System.Object Read3_Object(bool isNullable, bool checkType) {
if (isNullable && ReadNull()) return null;
if (checkType) {
System.Xml.XmlQualifiedName t = GetXsiType();
if (t == null)
return ReadTypedPrimitive(new
System.Xml.XmlQualifiedName("anyType", "http://www.w3.org/2001/XMLSchema"));
else if (((object) ((System.Xml.XmlQualifiedName)t).Name ==
(object)id15_MarshalByRefObject && (object)
((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item))
return Read2_MarshalByRefObject(isNullable, false);
else if (((object) ((System.Xml.XmlQualifiedName)t).Name ==
(object)id1_SqlParameter && (object)
((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item))
return Read1_SqlParameter(isNullable, false);
else if (((object) ((System.Xml.XmlQualifiedName)t).Name ==
(object)id3_DbType && (object) ((System.Xml.XmlQualifiedName)t).Namespace ==
(object)id2_Item)) {
Reader.ReadStartElement();
object e = Read4_DbType(Reader.ReadString());
ReadEndElement();
return e;
}
else if (((object) ((System.Xml.XmlQualifiedName)t).Name ==
(object)id4_SqlDbType && (object) ((System.Xml.XmlQualifiedName)t).Namespace
== (object)id2_Item)) {
Reader.ReadStartElement();
object e = Read5_SqlDbType(Reader.ReadString());
ReadEndElement();
return e;
}
else if (((object) ((System.Xml.XmlQualifiedName)t).Name ==
(object)id16_ParameterDirection && (object)
((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item)) {
Reader.ReadStartElement();
object e = Read6_ParameterDirection(Reader.ReadString());
ReadEndElement();
return e;
}
else if (((object) ((System.Xml.XmlQualifiedName)t).Name ==
(object)id17_DataRowVersion && (object)
((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item)) {
Reader.ReadStartElement();
object e = Read7_DataRowVersion(Reader.ReadString());
ReadEndElement();
return e;
}
else
return ReadTypedPrimitive((System.Xml.XmlQualifiedName)t);
}
System.Object o = new System.Object();
bool[] paramsRead = new bool[0];
while (Reader.MoveToNextAttribute()) {
if (!IsXmlnsAttribute(Reader.Name)) {
UnknownNode((object)o);
}
}
Reader.MoveToElement();
if (Reader.IsEmptyElement) {
Reader.Skip();
return o;
}
Reader.ReadStartElement();
Reader.MoveToContent();
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) {
if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
UnknownNode((object)o);
}
else {
UnknownNode((object)o);
}
Reader.MoveToContent();
}
ReadEndElement();
return o;
}

System.Data.DbType Read4_DbType(string s) {
switch (s) {
case @"AnsiString": return System.Data.DbType.@AnsiString;
case @"Binary": return System.Data.DbType.@Binary;
case @"Byte": return System.Data.DbType.@Byte;
case @"Boolean": return System.Data.DbType.@Boolean;
case @"Currency": return System.Data.DbType.@Currency;
case @"Date": return System.Data.DbType.@Date;
case @"DateTime": return System.Data.DbType.@DateTime;
case @"Decimal": return System.Data.DbType.@Decimal;
case @"Double": return System.Data.DbType.@Double;
case @"Guid": return System.Data.DbType.@Guid;
case @"Int16": return System.Data.DbType.@Int16;
case @"Int32": return System.Data.DbType.@Int32;
case @"Int64": return System.Data.DbType.@Int64;
case @"Object": return System.Data.DbType.@Object;
case @"SByte": return System.Data.DbType.@SByte;
case @"Single": return System.Data.DbType.@Single;
case @"String": return System.Data.DbType.@String;
case @"Time": return System.Data.DbType.@Time;
case @"UInt16": return System.Data.DbType.@UInt16;
case @"UInt32": return System.Data.DbType.@UInt32;
case @"UInt64": return System.Data.DbType.@UInt64;
case @"VarNumeric": return System.Data.DbType.@VarNumeric;
case @"AnsiStringFixedLength": return
System.Data.DbType.@AnsiStringFixedLength;
case @"StringFixedLength": return
System.Data.DbType.@StringFixedLength;
default: throw CreateUnknownConstantException(s,
typeof(System.Data.DbType));
}
}

System.Data.SqlDbType Read5_SqlDbType(string s) {
switch (s) {
case @"BigInt": return System.Data.SqlDbType.@BigInt;
case @"Binary": return System.Data.SqlDbType.@Binary;
case @"Bit": return System.Data.SqlDbType.@Bit;
case @"Char": return System.Data.SqlDbType.@Char;
case @"DateTime": return System.Data.SqlDbType.@DateTime;
case @"Decimal": return System.Data.SqlDbType.@Decimal;
case @"Float": return System.Data.SqlDbType.@Float;
case @"Image": return System.Data.SqlDbType.@Image;
case @"Int": return System.Data.SqlDbType.@Int;
case @"Money": return System.Data.SqlDbType.@Money;
case @"NChar": return System.Data.SqlDbType.@NChar;
case @"NText": return System.Data.SqlDbType.@NText;
case @"NVarChar": return System.Data.SqlDbType.@NVarChar;
case @"Real": return System.Data.SqlDbType.@Real;
case @"UniqueIdentifier": return
System.Data.SqlDbType.@UniqueIdentifier;
case @"SmallDateTime": return
System.Data.SqlDbType.@SmallDateTime;
case @"SmallInt": return System.Data.SqlDbType.@SmallInt;
case @"SmallMoney": return System.Data.SqlDbType.@SmallMoney;
case @"Text": return System.Data.SqlDbType.@Text;
case @"Timestamp": return System.Data.SqlDbType.@Timestamp;
case @"TinyInt": return System.Data.SqlDbType.@TinyInt;
case @"VarBinary": return System.Data.SqlDbType.@VarBinary;
case @"VarChar": return System.Data.SqlDbType.@VarChar;
case @"Variant": return System.Data.SqlDbType.@Variant;
default: throw CreateUnknownConstantException(s,
typeof(System.Data.SqlDbType));
}
}

System.Data.ParameterDirection Read6_ParameterDirection(string s) {
switch (s) {
case @"Input": return System.Data.ParameterDirection.@Input;
case @"Output": return System.Data.ParameterDirection.@Output;
case @"InputOutput": return
System.Data.ParameterDirection.@InputOutput;
case @"ReturnValue": return
System.Data.ParameterDirection.@ReturnValue;
default: throw CreateUnknownConstantException(s,
typeof(System.Data.ParameterDirection));
}
}

System.Data.DataRowVersion Read7_DataRowVersion(string s) {
switch (s) {
case @"Original": return System.Data.DataRowVersion.@Original;
case @"Current": return System.Data.DataRowVersion.@Current;
case @"Proposed": return System.Data.DataRowVersion.@Proposed;
case @"Default": return System.Data.DataRowVersion.@Default;
default: throw CreateUnknownConstantException(s,
typeof(System.Data.DataRowVersion));
}
}

protected override void InitCallbacks() {
}

public object Read9_SqlParameter() {
object o = null;
Reader.MoveToContent();
if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
if (((object) Reader.LocalName == (object)id1_SqlParameter
&& (object) Reader.NamespaceURI == (object)id2_Item)) {
o = Read1_SqlParameter(true, true);
}
else {
throw CreateUnknownNodeException();
}
}
else {
UnknownNode(null);
}
return (object)o;
}

System.String id10_Scale;
System.String id16_ParameterDirection;
System.String id7_Offset;
System.String id15_MarshalByRefObject;
System.String id1_SqlParameter;
System.String id14_Value;
System.String id12_SourceColumn;
System.String id5_Direction;
System.String id13_SourceVersion;
System.String id2_Item;
System.String id3_DbType;
System.String id11_Size;
System.String id9_Precision;
System.String id4_SqlDbType;
System.String id17_DataRowVersion;
System.String id8_ParameterName;
System.String id6_IsNullable;

protected override void InitIDs() {
id10_Scale = Reader.NameTable.Add(@"Scale");
id16_ParameterDirection =
Reader.NameTable.Add(@"ParameterDirection");
id7_Offset = Reader.NameTable.Add(@"Offset");
id15_MarshalByRefObject =
Reader.NameTable.Add(@"MarshalByRefObject");
id1_SqlParameter = Reader.NameTable.Add(@"SqlParameter");
id14_Value = Reader.NameTable.Add(@"Value");
id12_SourceColumn = Reader.NameTable.Add(@"SourceColumn");
id5_Direction = Reader.NameTable.Add(@"Direction");
id13_SourceVersion = Reader.NameTable.Add(@"SourceVersion");
id2_Item = Reader.NameTable.Add(@"");
id3_DbType = Reader.NameTable.Add(@"DbType");
id11_Size = Reader.NameTable.Add(@"Size");
id9_Precision = Reader.NameTable.Add(@"Precision");
id4_SqlDbType = Reader.NameTable.Add(@"SqlDbType");
id17_DataRowVersion = Reader.NameTable.Add(@"DataRowVersion");
id8_ParameterName = Reader.NameTable.Add(@"ParameterName");
id6_IsNullable = Reader.NameTable.Add(@"IsNullable");
}
}
}
 
Thanks to Outlook Express here comes the .NET 2.0 XMLSerializer for
SqlParameter:

#if _DYNAMIC_XMLSERIALIZER_COMPILATION
[assembly:System.Security.AllowPartiallyTrustedCallers()]
[assembly:System.Security.SecurityTransparent()]
#endif
[assembly:System.Reflection.AssemblyVersionAttribute("2.0.0.0")]
[assembly:System.Xml.Serialization.XmlSerializerVersionAttribute(ParentAssemblyId=@"70bbeca7-72bc-4c00-862b-642b5f48a565,",
Version=@"2.0.0.0")]
namespace Microsoft.Xml.Serialization.GeneratedAssembly {

public class XmlSerializationWriterSqlParameter :
System.Xml.Serialization.XmlSerializationWriter {

public void Write10_SqlParameter(object o) {
WriteStartDocument();
if (o == null) {
WriteNullTagLiteral(@"SqlParameter", @"");
return;
}
TopLevelElement();
Write9_SqlParameter(@"SqlParameter", @"",
((global::System.Data.SqlClient.SqlParameter)o), true, false);
}

void Write9_SqlParameter(string n, string ns,
global::System.Data.SqlClient.SqlParameter o, bool isNullable, bool
needType) {
if ((object)o == null) {
if (isNullable) WriteNullTagLiteral(n, ns);
return;
}
if (!needType) {
System.Type t = o.GetType();
if (t == typeof(global::System.Data.SqlClient.SqlParameter))
{
}
else {
throw CreateUnknownTypeException(o);
}
}
WriteStartElement(n, ns, o, false, null);
if (needType) WriteXsiType(@"SqlParameter", @"");
WriteElementString(@"DbType", @"",
Write3_DbType(((global::System.Data.DbType)o.@DbType)));
if (((global::System.Data.ParameterDirection)o.@Direction) !=
global::System.Data.ParameterDirection.@Input) {
WriteElementString(@"Direction", @"",
Write4_ParameterDirection(((global::System.Data.ParameterDirection)o.@Direction)));
}
WriteElementStringRaw(@"IsNullable", @"",
System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@IsNullable)));
if ((((global::System.String)o.@ParameterName) != null) &&
(((global::System.String)o.@ParameterName).Length != 0)) {
WriteElementString(@"ParameterName", @"",
((global::System.String)o.@ParameterName));
}
WriteElementStringRaw(@"Size", @"",
System.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@Size)));
if ((((global::System.String)o.@SourceColumn) != null) &&
(((global::System.String)o.@SourceColumn).Length != 0)) {
WriteElementString(@"SourceColumn", @"",
((global::System.String)o.@SourceColumn));
}
if (((global::System.Boolean)o.@SourceColumnNullMapping) !=
false) {
WriteElementStringRaw(@"SourceColumnNullMapping", @"",
System.Xml.XmlConvert.ToString((global::System.Boolean)((global::System.Boolean)o.@SourceColumnNullMapping)));
}
if (((global::System.Data.DataRowVersion)o.@SourceVersion) !=
global::System.Data.DataRowVersion.@Current) {
WriteElementString(@"SourceVersion", @"",
Write5_DataRowVersion(((global::System.Data.DataRowVersion)o.@SourceVersion)));
}
Write1_Object(@"Value", @"", ((global::System.Object)o.@Value),
false, false);
WriteElementString(@"CompareInfo", @"",
Write7_SqlCompareOptions(((global::System.Data.SqlTypes.SqlCompareOptions)o.@CompareInfo)));
WriteElementString(@"XmlSchemaCollectionDatabase", @"",
((global::System.String)o.@XmlSchemaCollectionDatabase));
WriteElementString(@"XmlSchemaCollectionOwningSchema", @"",
((global::System.String)o.@XmlSchemaCollectionOwningSchema));
WriteElementString(@"XmlSchemaCollectionName", @"",
((global::System.String)o.@XmlSchemaCollectionName));
WriteElementStringRaw(@"LocaleId", @"",
System.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@LocaleId)));
if (((global::System.Byte)o.@Precision) != (System.Byte)(0)) {
WriteElementStringRaw(@"Precision", @"",
System.Xml.XmlConvert.ToString((global::System.Byte)((global::System.Byte)o.@Precision)));
}
if (((global::System.Byte)o.@Scale) != (System.Byte)(0)) {
WriteElementStringRaw(@"Scale", @"",
System.Xml.XmlConvert.ToString((global::System.Byte)((global::System.Byte)o.@Scale)));
}
WriteElementString(@"SqlDbType", @"",
Write8_SqlDbType(((global::System.Data.SqlDbType)o.@SqlDbType)));
Write1_Object(@"SqlValue", @"",
((global::System.Object)o.@SqlValue), false, false);
WriteElementString(@"UdtTypeName", @"",
((global::System.String)o.@UdtTypeName));
WriteElementStringRaw(@"Offset", @"",
System.Xml.XmlConvert.ToString((global::System.Int32)((global::System.Int32)o.@Offset)));
WriteEndElement(o);
}

void Write1_Object(string n, string ns, global::System.Object o,
bool isNullable, bool needType) {
if ((object)o == null) {
if (isNullable) WriteNullTagLiteral(n, ns);
return;
}
if (!needType) {
System.Type t = o.GetType();
if (t == typeof(global::System.Object)) {
}
else if (t == typeof(global::System.MarshalByRefObject)) {
Write2_MarshalByRefObject(n,
ns,(global::System.MarshalByRefObject)o, isNullable, true);
return;
}
else if (t ==
typeof(global::System.Data.Common.DbParameter)) {
Write6_DbParameter(n,
ns,(global::System.Data.Common.DbParameter)o, isNullable, true);
return;
}
else if (t ==
typeof(global::System.Data.SqlClient.SqlParameter)) {
Write9_SqlParameter(n,
ns,(global::System.Data.SqlClient.SqlParameter)o, isNullable, true);
return;
}
else if (t == typeof(global::System.Data.DbType)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"DbType", @"");
Writer.WriteString(Write3_DbType((global::System.Data.DbType)o));
Writer.WriteEndElement();
return;
}
else if (t ==
typeof(global::System.Data.ParameterDirection)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"ParameterDirection", @"");
Writer.WriteString(Write4_ParameterDirection((global::System.Data.ParameterDirection)o));
Writer.WriteEndElement();
return;
}
else if (t == typeof(global::System.Data.DataRowVersion)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"DataRowVersion", @"");
Writer.WriteString(Write5_DataRowVersion((global::System.Data.DataRowVersion)o));
Writer.WriteEndElement();
return;
}
else if (t ==
typeof(global::System.Data.SqlTypes.SqlCompareOptions)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"SqlCompareOptions", @"");
Writer.WriteString(Write7_SqlCompareOptions((global::System.Data.SqlTypes.SqlCompareOptions)o));
Writer.WriteEndElement();
return;
}
else if (t == typeof(global::System.Data.SqlDbType)) {
Writer.WriteStartElement(n, ns);
WriteXsiType(@"SqlDbType", @"");
Writer.WriteString(Write8_SqlDbType((global::System.Data.SqlDbType)o));
Writer.WriteEndElement();
return;
}
else {
WriteTypedPrimitive(n, ns, o, true);
return;
}
}
WriteStartElement(n, ns, o, false, null);
WriteEndElement(o);
}

string Write8_SqlDbType(global::System.Data.SqlDbType v) {
string s = null;
switch (v) {
case global::System.Data.SqlDbType.@BigInt: s = @"BigInt";
break;
case global::System.Data.SqlDbType.@Binary: s = @"Binary";
break;
case global::System.Data.SqlDbType.@Bit: s = @"Bit"; break;
case global::System.Data.SqlDbType.@Char: s = @"Char";
break;
case global::System.Data.SqlDbType.@DateTime: s =
@"DateTime"; break;
case global::System.Data.SqlDbType.@Decimal: s = @"Decimal";
break;
case global::System.Data.SqlDbType.@Float: s = @"Float";
break;
case global::System.Data.SqlDbType.@Image: s = @"Image";
break;
case global::System.Data.SqlDbType.@Int: s = @"Int"; break;
case global::System.Data.SqlDbType.@Money: s = @"Money";
break;
case global::System.Data.SqlDbType.@NChar: s = @"NChar";
break;
case global::System.Data.SqlDbType.@NText: s = @"NText";
break;
case global::System.Data.SqlDbType.@NVarChar: s =
@"NVarChar"; break;
case global::System.Data.SqlDbType.@Real: s = @"Real";
break;
case global::System.Data.SqlDbType.@UniqueIdentifier: s =
@"UniqueIdentifier"; break;
case global::System.Data.SqlDbType.@SmallDateTime: s =
@"SmallDateTime"; break;
case global::System.Data.SqlDbType.@SmallInt: s =
@"SmallInt"; break;
case global::System.Data.SqlDbType.@SmallMoney: s =
@"SmallMoney"; break;
case global::System.Data.SqlDbType.@Text: s = @"Text";
break;
case global::System.Data.SqlDbType.@Timestamp: s =
@"Timestamp"; break;
case global::System.Data.SqlDbType.@TinyInt: s = @"TinyInt";
break;
case global::System.Data.SqlDbType.@VarBinary: s =
@"VarBinary"; break;
case global::System.Data.SqlDbType.@VarChar: s = @"VarChar";
break;
case global::System.Data.SqlDbType.@Variant: s = @"Variant";
break;
case global::System.Data.SqlDbType.@Xml: s = @"Xml"; break;
case global::System.Data.SqlDbType.@Udt: s = @"Udt"; break;
default: throw
CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture),
@"System.Data.SqlDbType");
}
return s;
}

string
Write7_SqlCompareOptions(global::System.Data.SqlTypes.SqlCompareOptions v) {
string s = null;
switch (v) {
case global::System.Data.SqlTypes.SqlCompareOptions.@None: s
= @"None"; break;
case
global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreCase: s =
@"IgnoreCase"; break;
case
global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreNonSpace: s =
@"IgnoreNonSpace"; break;
case
global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreKanaType: s =
@"IgnoreKanaType"; break;
case
global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreWidth: s =
@"IgnoreWidth"; break;
case
global::System.Data.SqlTypes.SqlCompareOptions.@BinarySort: s =
@"BinarySort"; break;
case
global::System.Data.SqlTypes.SqlCompareOptions.@BinarySort2: s =
@"BinarySort2"; break;
default: s = FromEnum(((System.Int64)v), new string[]
{@"None",
@"IgnoreCase",
@"IgnoreNonSpace",
@"IgnoreKanaType",
@"IgnoreWidth",
@"BinarySort",
@"BinarySort2"}, new System.Int64[]
{(long)global::System.Data.SqlTypes.SqlCompareOptions.@None,
(long)global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreCase,
(long)global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreNonSpace,
(long)global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreKanaType,
(long)global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreWidth,
(long)global::System.Data.SqlTypes.SqlCompareOptions.@BinarySort,
(long)global::System.Data.SqlTypes.SqlCompareOptions.@BinarySort2},
@"System.Data.SqlTypes.SqlCompareOptions"); break;
}
return s;
}

string Write5_DataRowVersion(global::System.Data.DataRowVersion v) {
string s = null;
switch (v) {
case global::System.Data.DataRowVersion.@Original: s =
@"Original"; break;
case global::System.Data.DataRowVersion.@Current: s =
@"Current"; break;
case global::System.Data.DataRowVersion.@Proposed: s =
@"Proposed"; break;
case global::System.Data.DataRowVersion.@Default: s =
@"Default"; break;
default: throw
CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture),
@"System.Data.DataRowVersion");
}
return s;
}

string
Write4_ParameterDirection(global::System.Data.ParameterDirection v) {
string s = null;
switch (v) {
case global::System.Data.ParameterDirection.@Input: s =
@"Input"; break;
case global::System.Data.ParameterDirection.@Output: s =
@"Output"; break;
case global::System.Data.ParameterDirection.@InputOutput: s
= @"InputOutput"; break;
case global::System.Data.ParameterDirection.@ReturnValue: s
= @"ReturnValue"; break;
default: throw
CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture),
@"System.Data.ParameterDirection");
}
return s;
}

string Write3_DbType(global::System.Data.DbType v) {
string s = null;
switch (v) {
case global::System.Data.DbType.@AnsiString: s =
@"AnsiString"; break;
case global::System.Data.DbType.@Binary: s = @"Binary";
break;
case global::System.Data.DbType.@Byte: s = @"Byte"; break;
case global::System.Data.DbType.@Boolean: s = @"Boolean";
break;
case global::System.Data.DbType.@Currency: s = @"Currency";
break;
case global::System.Data.DbType.@Date: s = @"Date"; break;
case global::System.Data.DbType.@DateTime: s = @"DateTime";
break;
case global::System.Data.DbType.@Decimal: s = @"Decimal";
break;
case global::System.Data.DbType.@Double: s = @"Double";
break;
case global::System.Data.DbType.@Guid: s = @"Guid"; break;
case global::System.Data.DbType.@Int16: s = @"Int16"; break;
case global::System.Data.DbType.@Int32: s = @"Int32"; break;
case global::System.Data.DbType.@Int64: s = @"Int64"; break;
case global::System.Data.DbType.@Object: s = @"Object";
break;
case global::System.Data.DbType.@SByte: s = @"SByte"; break;
case global::System.Data.DbType.@Single: s = @"Single";
break;
case global::System.Data.DbType.@String: s = @"String";
break;
case global::System.Data.DbType.@Time: s = @"Time"; break;
case global::System.Data.DbType.@UInt16: s = @"UInt16";
break;
case global::System.Data.DbType.@UInt32: s = @"UInt32";
break;
case global::System.Data.DbType.@UInt64: s = @"UInt64";
break;
case global::System.Data.DbType.@VarNumeric: s =
@"VarNumeric"; break;
case global::System.Data.DbType.@AnsiStringFixedLength: s =
@"AnsiStringFixedLength"; break;
case global::System.Data.DbType.@StringFixedLength: s =
@"StringFixedLength"; break;
case global::System.Data.DbType.@Xml: s = @"Xml"; break;
default: throw
CreateInvalidEnumValueException(((System.Int64)v).ToString(System.Globalization.CultureInfo.InvariantCulture),
@"System.Data.DbType");
}
return s;
}

void Write6_DbParameter(string n, string ns,
global::System.Data.Common.DbParameter o, bool isNullable, bool needType) {
if ((object)o == null) {
if (isNullable) WriteNullTagLiteral(n, ns);
return;
}
if (!needType) {
System.Type t = o.GetType();
if (t == typeof(global::System.Data.Common.DbParameter)) {
}
else if (t ==
typeof(global::System.Data.SqlClient.SqlParameter)) {
Write9_SqlParameter(n,
ns,(global::System.Data.SqlClient.SqlParameter)o, isNullable, true);
return;
}
else {
throw CreateUnknownTypeException(o);
}
}
}

void Write2_MarshalByRefObject(string n, string ns,
global::System.MarshalByRefObject o, bool isNullable, bool needType) {
if ((object)o == null) {
if (isNullable) WriteNullTagLiteral(n, ns);
return;
}
if (!needType) {
System.Type t = o.GetType();
if (t == typeof(global::System.MarshalByRefObject)) {
}
else if (t ==
typeof(global::System.Data.Common.DbParameter)) {
Write6_DbParameter(n,
ns,(global::System.Data.Common.DbParameter)o, isNullable, true);
return;
}
else if (t ==
typeof(global::System.Data.SqlClient.SqlParameter)) {
Write9_SqlParameter(n,
ns,(global::System.Data.SqlClient.SqlParameter)o, isNullable, true);
return;
}
else {
throw CreateUnknownTypeException(o);
}
}
}

protected override void InitCallbacks() {
}
}

public class XmlSerializationReaderSqlParameter :
System.Xml.Serialization.XmlSerializationReader {

public object Read10_SqlParameter() {
object o = null;
Reader.MoveToContent();
if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
if (((object) Reader.LocalName == (object)id1_SqlParameter
&& (object) Reader.NamespaceURI == (object)id2_Item)) {
o = Read9_SqlParameter(true, true);
}
else {
throw CreateUnknownNodeException();
}
}
else {
UnknownNode(null, @":SqlParameter");
}
return (object)o;
}

global::System.Data.SqlClient.SqlParameter Read9_SqlParameter(bool
isNullable, bool checkType) {
System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() :
null;
bool isNull = false;
if (isNullable) isNull = ReadNull();
if (checkType) {
if (xsiType == null || ((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id1_SqlParameter &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item)) {
}
else
throw
CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
}
if (isNull) return null;
global::System.Data.SqlClient.SqlParameter o;
o = new global::System.Data.SqlClient.SqlParameter();
bool[] paramsRead = new bool[20];
while (Reader.MoveToNextAttribute()) {
if (!IsXmlnsAttribute(Reader.Name)) {
UnknownNode((object)o);
}
}
Reader.MoveToElement();
if (Reader.IsEmptyElement) {
Reader.Skip();
return o;
}
Reader.ReadStartElement();
Reader.MoveToContent();
int whileIterations0 = 0;
int readerCount0 = ReaderCount;
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement &&
Reader.NodeType != System.Xml.XmlNodeType.None) {
if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
if (!paramsRead[0] && ((object) Reader.LocalName ==
(object)id3_DbType && (object) Reader.NamespaceURI == (object)id2_Item)) {
{
o.@DbType =
Read3_DbType(Reader.ReadElementString());
}
paramsRead[0] = true;
}
else if (!paramsRead[1] && ((object) Reader.LocalName ==
(object)id4_Direction && (object) Reader.NamespaceURI == (object)id2_Item))
{
if (Reader.IsEmptyElement) {
Reader.Skip();
}
else {
o.@Direction =
Read4_ParameterDirection(Reader.ReadElementString());
}
paramsRead[1] = true;
}
else if (!paramsRead[2] && ((object) Reader.LocalName ==
(object)id5_IsNullable && (object) Reader.NamespaceURI == (object)id2_Item))
{
{
o.@IsNullable =
System.Xml.XmlConvert.ToBoolean(Reader.ReadElementString());
}
paramsRead[2] = true;
}
else if (!paramsRead[3] && ((object) Reader.LocalName ==
(object)id6_ParameterName && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
{
o.@ParameterName = Reader.ReadElementString();
}
paramsRead[3] = true;
}
else if (!paramsRead[4] && ((object) Reader.LocalName ==
(object)id7_Size && (object) Reader.NamespaceURI == (object)id2_Item)) {
{
o.@Size =
System.Xml.XmlConvert.ToInt32(Reader.ReadElementString());
}
paramsRead[4] = true;
}
else if (!paramsRead[5] && ((object) Reader.LocalName ==
(object)id8_SourceColumn && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
{
o.@SourceColumn = Reader.ReadElementString();
}
paramsRead[5] = true;
}
else if (!paramsRead[6] && ((object) Reader.LocalName ==
(object)id9_SourceColumnNullMapping && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
if (Reader.IsEmptyElement) {
Reader.Skip();
}
else {
o.@SourceColumnNullMapping =
System.Xml.XmlConvert.ToBoolean(Reader.ReadElementString());
}
paramsRead[6] = true;
}
else if (!paramsRead[7] && ((object) Reader.LocalName ==
(object)id10_SourceVersion && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
if (Reader.IsEmptyElement) {
Reader.Skip();
}
else {
o.@SourceVersion =
Read5_DataRowVersion(Reader.ReadElementString());
}
paramsRead[7] = true;
}
else if (!paramsRead[8] && ((object) Reader.LocalName ==
(object)id11_Value && (object) Reader.NamespaceURI == (object)id2_Item)) {
o.@Value = Read1_Object(false, true);
paramsRead[8] = true;
}
else if (!paramsRead[9] && ((object) Reader.LocalName ==
(object)id12_CompareInfo && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
{
o.@CompareInfo =
Read7_SqlCompareOptions(Reader.ReadElementString());
}
paramsRead[9] = true;
}
else if (!paramsRead[10] && ((object) Reader.LocalName
== (object)id13_XmlSchemaCollectionDatabase && (object) Reader.NamespaceURI
== (object)id2_Item)) {
{
o.@XmlSchemaCollectionDatabase =
Reader.ReadElementString();
}
paramsRead[10] = true;
}
else if (!paramsRead[11] && ((object) Reader.LocalName
== (object)id14_Item && (object) Reader.NamespaceURI == (object)id2_Item)) {
{
o.@XmlSchemaCollectionOwningSchema =
Reader.ReadElementString();
}
paramsRead[11] = true;
}
else if (!paramsRead[12] && ((object) Reader.LocalName
== (object)id15_XmlSchemaCollectionName && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
{
o.@XmlSchemaCollectionName =
Reader.ReadElementString();
}
paramsRead[12] = true;
}
else if (!paramsRead[13] && ((object) Reader.LocalName
== (object)id16_LocaleId && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
{
o.@LocaleId =
System.Xml.XmlConvert.ToInt32(Reader.ReadElementString());
}
paramsRead[13] = true;
}
else if (!paramsRead[14] && ((object) Reader.LocalName
== (object)id17_Precision && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
if (Reader.IsEmptyElement) {
Reader.Skip();
}
else {
o.@Precision =
System.Xml.XmlConvert.ToByte(Reader.ReadElementString());
}
paramsRead[14] = true;
}
else if (!paramsRead[15] && ((object) Reader.LocalName
== (object)id18_Scale && (object) Reader.NamespaceURI == (object)id2_Item))
{
if (Reader.IsEmptyElement) {
Reader.Skip();
}
else {
o.@Scale =
System.Xml.XmlConvert.ToByte(Reader.ReadElementString());
}
paramsRead[15] = true;
}
else if (!paramsRead[16] && ((object) Reader.LocalName
== (object)id19_SqlDbType && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
{
o.@SqlDbType =
Read8_SqlDbType(Reader.ReadElementString());
}
paramsRead[16] = true;
}
else if (!paramsRead[17] && ((object) Reader.LocalName
== (object)id20_SqlValue && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
o.@SqlValue = Read1_Object(false, true);
paramsRead[17] = true;
}
else if (!paramsRead[18] && ((object) Reader.LocalName
== (object)id21_UdtTypeName && (object) Reader.NamespaceURI ==
(object)id2_Item)) {
{
o.@UdtTypeName = Reader.ReadElementString();
}
paramsRead[18] = true;
}
else if (!paramsRead[19] && ((object) Reader.LocalName
== (object)id22_Offset && (object) Reader.NamespaceURI == (object)id2_Item))
{
{
o.@Offset =
System.Xml.XmlConvert.ToInt32(Reader.ReadElementString());
}
paramsRead[19] = true;
}
else {
UnknownNode((object)o, @":DbType, :Direction,
:IsNullable, :ParameterName, :Size, :SourceColumn, :SourceColumnNullMapping,
:SourceVersion, :Value, :CompareInfo, :XmlSchemaCollectionDatabase,
:XmlSchemaCollectionOwningSchema, :XmlSchemaCollectionName, :LocaleId,
:Precision, :Scale, :SqlDbType, :SqlValue, :UdtTypeName, :Offset");
}
}
else {
UnknownNode((object)o, @":DbType, :Direction,
:IsNullable, :ParameterName, :Size, :SourceColumn, :SourceColumnNullMapping,
:SourceVersion, :Value, :CompareInfo, :XmlSchemaCollectionDatabase,
:XmlSchemaCollectionOwningSchema, :XmlSchemaCollectionName, :LocaleId,
:Precision, :Scale, :SqlDbType, :SqlValue, :UdtTypeName, :Offset");
}
Reader.MoveToContent();
CheckReaderCount(ref whileIterations0, ref readerCount0);
}
ReadEndElement();
return o;
}

global::System.Object Read1_Object(bool isNullable, bool checkType)
{
System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() :
null;
bool isNull = false;
if (isNullable) isNull = ReadNull();
if (checkType) {
if (isNull) {
if (xsiType != null) return
(global::System.Object)ReadTypedNull(xsiType);
else return null;
}
if (xsiType == null) {
return ReadTypedPrimitive(new
System.Xml.XmlQualifiedName("anyType", "http://www.w3.org/2001/XMLSchema"));
}
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name ==
(object)id23_MarshalByRefObject && (object)
((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item))
return Read2_MarshalByRefObject(isNullable, false);
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id24_DbParameter &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item))
return Read6_DbParameter(isNullable, false);
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id1_SqlParameter &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item))
return Read9_SqlParameter(isNullable, false);
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_DbType &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item)) {
Reader.ReadStartElement();
object e =
Read3_DbType(CollapseWhitespace(Reader.ReadString()));
ReadEndElement();
return e;
}
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name ==
(object)id25_ParameterDirection && (object)
((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) {
Reader.ReadStartElement();
object e =
Read4_ParameterDirection(CollapseWhitespace(Reader.ReadString()));
ReadEndElement();
return e;
}
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id26_DataRowVersion
&& (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item)) {
Reader.ReadStartElement();
object e =
Read5_DataRowVersion(CollapseWhitespace(Reader.ReadString()));
ReadEndElement();
return e;
}
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name ==
(object)id27_SqlCompareOptions && (object)
((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) {
Reader.ReadStartElement();
object e =
Read7_SqlCompareOptions(CollapseWhitespace(Reader.ReadString()));
ReadEndElement();
return e;
}
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id19_SqlDbType &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item)) {
Reader.ReadStartElement();
object e =
Read8_SqlDbType(CollapseWhitespace(Reader.ReadString()));
ReadEndElement();
return e;
}
else
return
ReadTypedPrimitive((System.Xml.XmlQualifiedName)xsiType);
}
if (isNull) return null;
global::System.Object o;
o = new global::System.Object();
bool[] paramsRead = new bool[0];
while (Reader.MoveToNextAttribute()) {
if (!IsXmlnsAttribute(Reader.Name)) {
UnknownNode((object)o);
}
}
Reader.MoveToElement();
if (Reader.IsEmptyElement) {
Reader.Skip();
return o;
}
Reader.ReadStartElement();
Reader.MoveToContent();
int whileIterations1 = 0;
int readerCount1 = ReaderCount;
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement
&& Reader.NodeType != System.Xml.XmlNodeType.None) {
if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
UnknownNode((object)o, @"");
}
else {
UnknownNode((object)o, @"");
}
Reader.MoveToContent();
CheckReaderCount(ref whileIterations1, ref
readerCount1);
}
ReadEndElement();
return o;
}

global::System.Data.SqlDbType Read8_SqlDbType(string s) {
switch (s) {
case @"BigInt": return
global::System.Data.SqlDbType.@BigInt;
case @"Binary": return
global::System.Data.SqlDbType.@Binary;
case @"Bit": return global::System.Data.SqlDbType.@Bit;
case @"Char": return
global::System.Data.SqlDbType.@Char;
case @"DateTime": return
global::System.Data.SqlDbType.@DateTime;
case @"Decimal": return
global::System.Data.SqlDbType.@Decimal;
case @"Float": return
global::System.Data.SqlDbType.@Float;
case @"Image": return
global::System.Data.SqlDbType.@Image;
case @"Int": return global::System.Data.SqlDbType.@Int;
case @"Money": return
global::System.Data.SqlDbType.@Money;
case @"NChar": return
global::System.Data.SqlDbType.@NChar;
case @"NText": return
global::System.Data.SqlDbType.@NText;
case @"NVarChar": return
global::System.Data.SqlDbType.@NVarChar;
case @"Real": return
global::System.Data.SqlDbType.@Real;
case @"UniqueIdentifier": return
global::System.Data.SqlDbType.@UniqueIdentifier;
case @"SmallDateTime": return
global::System.Data.SqlDbType.@SmallDateTime;
case @"SmallInt": return
global::System.Data.SqlDbType.@SmallInt;
case @"SmallMoney": return
global::System.Data.SqlDbType.@SmallMoney;
case @"Text": return
global::System.Data.SqlDbType.@Text;
case @"Timestamp": return
global::System.Data.SqlDbType.@Timestamp;
case @"TinyInt": return
global::System.Data.SqlDbType.@TinyInt;
case @"VarBinary": return
global::System.Data.SqlDbType.@VarBinary;
case @"VarChar": return
global::System.Data.SqlDbType.@VarChar;
case @"Variant": return
global::System.Data.SqlDbType.@Variant;
case @"Xml": return global::System.Data.SqlDbType.@Xml;
case @"Udt": return global::System.Data.SqlDbType.@Udt;
default: throw CreateUnknownConstantException(s,
typeof(global::System.Data.SqlDbType));
}
}

System.Collections.Hashtable _SqlCompareOptionsValues;

internal System.Collections.Hashtable SqlCompareOptionsValues {
get {
if ((object)_SqlCompareOptionsValues == null) {
System.Collections.Hashtable h = new
System.Collections.Hashtable();
h.Add(@"None",
(long)global::System.Data.SqlTypes.SqlCompareOptions.@None);
h.Add(@"IgnoreCase",
(long)global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreCase);
h.Add(@"IgnoreNonSpace",
(long)global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreNonSpace);
h.Add(@"IgnoreKanaType",
(long)global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreKanaType);
h.Add(@"IgnoreWidth",
(long)global::System.Data.SqlTypes.SqlCompareOptions.@IgnoreWidth);
h.Add(@"BinarySort",
(long)global::System.Data.SqlTypes.SqlCompareOptions.@BinarySort);
h.Add(@"BinarySort2",
(long)global::System.Data.SqlTypes.SqlCompareOptions.@BinarySort2);
_SqlCompareOptionsValues = h;
}
return _SqlCompareOptionsValues;
}
}

global::System.Data.SqlTypes.SqlCompareOptions
Read7_SqlCompareOptions(string s) {
return
(global::System.Data.SqlTypes.SqlCompareOptions)ToEnum(s,
SqlCompareOptionsValues, @"global::System.Data.SqlTypes.SqlCompareOptions");
}

global::System.Data.DataRowVersion Read5_DataRowVersion(string
s) {
switch (s) {
case @"Original": return
global::System.Data.DataRowVersion.@Original;
case @"Current": return
global::System.Data.DataRowVersion.@Current;
case @"Proposed": return
global::System.Data.DataRowVersion.@Proposed;
case @"Default": return
global::System.Data.DataRowVersion.@Default;
default: throw CreateUnknownConstantException(s,
typeof(global::System.Data.DataRowVersion));
}
}

global::System.Data.ParameterDirection
Read4_ParameterDirection(string s) {
switch (s) {
case @"Input": return
global::System.Data.ParameterDirection.@Input;
case @"Output": return
global::System.Data.ParameterDirection.@Output;
case @"InputOutput": return
global::System.Data.ParameterDirection.@InputOutput;
case @"ReturnValue": return
global::System.Data.ParameterDirection.@ReturnValue;
default: throw CreateUnknownConstantException(s,
typeof(global::System.Data.ParameterDirection));
}
}

global::System.Data.DbType Read3_DbType(string s) {
switch (s) {
case @"AnsiString": return
global::System.Data.DbType.@AnsiString;
case @"Binary": return
global::System.Data.DbType.@Binary;
case @"Byte": return global::System.Data.DbType.@Byte;
case @"Boolean": return
global::System.Data.DbType.@Boolean;
case @"Currency": return
global::System.Data.DbType.@Currency;
case @"Date": return global::System.Data.DbType.@Date;
case @"DateTime": return
global::System.Data.DbType.@DateTime;
case @"Decimal": return
global::System.Data.DbType.@Decimal;
case @"Double": return
global::System.Data.DbType.@Double;
case @"Guid": return global::System.Data.DbType.@Guid;
case @"Int16": return global::System.Data.DbType.@Int16;
case @"Int32": return global::System.Data.DbType.@Int32;
case @"Int64": return global::System.Data.DbType.@Int64;
case @"Object": return
global::System.Data.DbType.@Object;
case @"SByte": return global::System.Data.DbType.@SByte;
case @"Single": return
global::System.Data.DbType.@Single;
case @"String": return
global::System.Data.DbType.@String;
case @"Time": return global::System.Data.DbType.@Time;
case @"UInt16": return
global::System.Data.DbType.@UInt16;
case @"UInt32": return
global::System.Data.DbType.@UInt32;
case @"UInt64": return
global::System.Data.DbType.@UInt64;
case @"VarNumeric": return
global::System.Data.DbType.@VarNumeric;
case @"AnsiStringFixedLength": return
global::System.Data.DbType.@AnsiStringFixedLength;
case @"StringFixedLength": return
global::System.Data.DbType.@StringFixedLength;
case @"Xml": return global::System.Data.DbType.@Xml;
default: throw CreateUnknownConstantException(s,
typeof(global::System.Data.DbType));
}
}

global::System.Data.Common.DbParameter Read6_DbParameter(bool
isNullable, bool checkType) {
System.Xml.XmlQualifiedName xsiType = checkType ?
GetXsiType() : null;
bool isNull = false;
if (isNullable) isNull = ReadNull();
if (checkType) {
if (xsiType == null || ((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id24_DbParameter &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item)) {
}
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id1_SqlParameter &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item))
return Read9_SqlParameter(isNullable, false);
else
throw
CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
}
if (isNull) return null;
throw CreateAbstractTypeException(@"DbParameter", @"");
}

global::System.MarshalByRefObject Read2_MarshalByRefObject(bool
isNullable, bool checkType) {
System.Xml.XmlQualifiedName xsiType = checkType ?
GetXsiType() : null;
bool isNull = false;
if (isNullable) isNull = ReadNull();
if (checkType) {
if (xsiType == null || ((object)
((System.Xml.XmlQualifiedName)xsiType).Name ==
(object)id23_MarshalByRefObject && (object)
((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) {
}
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id24_DbParameter &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item))
return Read6_DbParameter(isNullable, false);
else if (((object)
((System.Xml.XmlQualifiedName)xsiType).Name == (object)id1_SqlParameter &&
(object) ((System.Xml.XmlQualifiedName)xsiType).Namespace ==
(object)id2_Item))
return Read9_SqlParameter(isNullable, false);
else
throw
CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
}
if (isNull) return null;
throw CreateAbstractTypeException(@"MarshalByRefObject",
@"");
}

protected override void InitCallbacks() {
}

string id14_Item;
string id5_IsNullable;
string id20_SqlValue;
string id27_SqlCompareOptions;
string id4_Direction;
string id8_SourceColumn;
string id6_ParameterName;
string id18_Scale;
string id26_DataRowVersion;
string id25_ParameterDirection;
string id11_Value;
string id19_SqlDbType;
string id2_Item;
string id10_SourceVersion;
string id21_UdtTypeName;
string id12_CompareInfo;
string id13_XmlSchemaCollectionDatabase;
string id1_SqlParameter;
string id16_LocaleId;
string id7_Size;
string id23_MarshalByRefObject;
string id9_SourceColumnNullMapping;
string id15_XmlSchemaCollectionName;
string id22_Offset;
string id17_Precision;
string id3_DbType;
string id24_DbParameter;

protected override void InitIDs() {
id14_Item =
Reader.NameTable.Add(@"XmlSchemaCollectionOwningSchema");
id5_IsNullable = Reader.NameTable.Add(@"IsNullable");
id20_SqlValue = Reader.NameTable.Add(@"SqlValue");
id27_SqlCompareOptions =
Reader.NameTable.Add(@"SqlCompareOptions");
id4_Direction = Reader.NameTable.Add(@"Direction");
id8_SourceColumn = Reader.NameTable.Add(@"SourceColumn");
id6_ParameterName = Reader.NameTable.Add(@"ParameterName");
id18_Scale = Reader.NameTable.Add(@"Scale");
id26_DataRowVersion =
Reader.NameTable.Add(@"DataRowVersion");
id25_ParameterDirection =
Reader.NameTable.Add(@"ParameterDirection");
id11_Value = Reader.NameTable.Add(@"Value");
id19_SqlDbType = Reader.NameTable.Add(@"SqlDbType");
id2_Item = Reader.NameTable.Add(@"");
id10_SourceVersion = Reader.NameTable.Add(@"SourceVersion");
id21_UdtTypeName = Reader.NameTable.Add(@"UdtTypeName");
id12_CompareInfo = Reader.NameTable.Add(@"CompareInfo");
id13_XmlSchemaCollectionDatabase =
Reader.NameTable.Add(@"XmlSchemaCollectionDatabase");
id1_SqlParameter = Reader.NameTable.Add(@"SqlParameter");
id16_LocaleId = Reader.NameTable.Add(@"LocaleId");
id7_Size = Reader.NameTable.Add(@"Size");
id23_MarshalByRefObject =
Reader.NameTable.Add(@"MarshalByRefObject");
id9_SourceColumnNullMapping =
Reader.NameTable.Add(@"SourceColumnNullMapping");
id15_XmlSchemaCollectionName =
Reader.NameTable.Add(@"XmlSchemaCollectionName");
id22_Offset = Reader.NameTable.Add(@"Offset");
id17_Precision = Reader.NameTable.Add(@"Precision");
id3_DbType = Reader.NameTable.Add(@"DbType");
id24_DbParameter = Reader.NameTable.Add(@"DbParameter");
}
}

public abstract class XmlSerializer1 :
System.Xml.Serialization.XmlSerializer {
protected override
System.Xml.Serialization.XmlSerializationReader CreateReader() {
return new XmlSerializationReaderSqlParameter();
}
protected override
System.Xml.Serialization.XmlSerializationWriter CreateWriter() {
return new XmlSerializationWriterSqlParameter();
}
}

public sealed class SqlParameterSerializer : XmlSerializer1 {

public override System.Boolean
CanDeserialize(System.Xml.XmlReader xmlReader) {
return xmlReader.IsStartElement(@"SqlParameter", @"");
}

protected override void Serialize(object objectToSerialize,
System.Xml.Serialization.XmlSerializationWriter writer) {
((XmlSerializationWriterSqlParameter)writer).Write10_SqlParameter(objectToSerialize);
}

protected override object
Deserialize(System.Xml.Serialization.XmlSerializationReader reader) {
return
((XmlSerializationReaderSqlParameter)reader).Read10_SqlParameter();
}
}

public class XmlSerializerContract :
global::System.Xml.Serialization.XmlSerializerImplementation {
public override
global::System.Xml.Serialization.XmlSerializationReader Reader { get {
return new XmlSerializationReaderSqlParameter(); } }
public override
global::System.Xml.Serialization.XmlSerializationWriter Writer { get {
return new XmlSerializationWriterSqlParameter(); } }
System.Collections.Hashtable readMethods = null;
public override System.Collections.Hashtable ReadMethods {
get {
if (readMethods == null) {
System.Collections.Hashtable _tmp = new
System.Collections.Hashtable();
_tmp[@"System.Data.SqlClient.SqlParameter::"] =
@"Read10_SqlParameter";
if (readMethods == null) readMethods = _tmp;
}
return readMethods;
}
}
System.Collections.Hashtable writeMethods = null;
public override System.Collections.Hashtable WriteMethods {
get {
if (writeMethods == null) {
System.Collections.Hashtable _tmp = new
System.Collections.Hashtable();
_tmp[@"System.Data.SqlClient.SqlParameter::"] =
@"Write10_SqlParameter";
if (writeMethods == null) writeMethods = _tmp;
}
return writeMethods;
}
}
System.Collections.Hashtable typedSerializers = null;
public override System.Collections.Hashtable TypedSerializers {
get {
if (typedSerializers == null) {
System.Collections.Hashtable _tmp = new
System.Collections.Hashtable();
_tmp.Add(@"System.Data.SqlClient.SqlParameter::",
new SqlParameterSerializer());
if (typedSerializers == null) typedSerializers =
_tmp;
}
return typedSerializers;
}
}
public override System.Boolean CanSerialize(System.Type type) {
if (type ==
typeof(global::System.Data.SqlClient.SqlParameter)) return true;
return false;
}
public override System.Xml.Serialization.XmlSerializer
GetSerializer(System.Type type) {
if (type ==
typeof(global::System.Data.SqlClient.SqlParameter)) return new
SqlParameterSerializer();
return null;
}
}
}
 
Hi MSDNAndi,

Thanks for your knowledge sharing.
So far if you still have any concern, please feel free to post here about
what is your qestion now.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Peter,

of course I still have a concern, since there is no solution in my postings.
I hope we did not lose the weekend now.
If I did not express the question clearly, then please help me understanding
that so I can write it in a better way next time. I thought it would be
obvious from the thread.
My developers need an actual reply regarding the topic since a _major_ code
rewrite would have to be done if we cannot XmlSerialize SqlParameter anymore.
In other words - we need to know if it is a bug and when there will be a
solution and what to do in the meantime about this on the first glance simple
question.


To summarize:
I need to serialize SqlParameter.
It worked in .NET 1.1. It does not work in .NET 2.0.

I merely tried to help with the analysis and expected it would shorten the
reply time or result in a more meaningful reply from Microsoft, or even with
a solution for the problem.


The questions as we stand sum up to:

Question 1:
What did your research result in so far? Which steps are you taking now?
Is this problem maybe mentioned somewhere in the differences of .NET
framework 1.1 to 2.0?

Question 2:
Please tell me how to XmlSerialize SqlParameter then in .NET 2.0.
(And please do not tell me now that I have to write my own
Serializer/Deserializer now.)
As I consider it a "bug" what happens here, this should be a workaround only
for the time being.

Question 3:
What is the _exact_ cause of the problem? (Bug in XmlSerializer / sgen.exe
code-generation or in WriteTypedPrimitive or something completely different?
).

Question 4:
Did you report the problem to the product group to the appropriate support
engineer or product group?

Question 5:
When can a fix be expected?




Kind regards,
 
Hi

So far I can reproduced the problem and I have reported to our product
team. And they are working on this issue, due to the process that may need
some time, I am sorry for that.

Also if you are really urgent with the issue, you may try to contact MSPSS
directly.
http://support.microsoft.com

BTW: if we confirm this is a problem in our product the incident will be
free.

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks for the reply,
even though the issue remains open.

Well, so since a solution does not seem to be arriving soon, we will have to
go for a significant code-rewrite to avoid using SqlParameter-objects
directly. Instead we will have to have a helper-class that encapsulates the
SqlParameter and "getting" the actual SqlParameter only when we need it from
the helper class.

Further:
Honestly, I do not see, how:
Also if you are really urgent with the issue, you may try to contact MSPSS
directly.
http://support.microsoft.com
should help?
What would be the difference in handling the next steps?
It is a problem that now lies with the product group, and why would support
services have a solution any faster (besides of the 48hours newsgroup
response time)?

BTW: if we confirm this is a problem in our product the incident will be
free.
This is a policy I strongly disliked from the very start:
"Agree to pay and maybe the fee will be waifed".
What would be appropriate:
1. A free "submit a problem with our product"-support.
or
2. simply automatically transfer the case to support services for free if in
the newsgroup it is determined that it seems to be a problem with a product.

Please take this "policy" comment to the appropriate channel.


Thanks,

Andi
 
Hi,

can you please reply to:
Further:
Honestly, I do not see, how:
should help?
What would be the difference in handling the next steps?
It is a problem that now lies with the product group, and why would support
services have a solution any faster (besides of the 48hours newsgroup
response time)?

And: did you forward my "Please take this "policy comment" of the previous
post to the appropriate channel?


How long can I expect
"So far I can reproduced the problem and I have reported to our product
team. And they are working on this issue, due to the process that may need
some time, I am sorry for that."
to take until I at least hear/read something here?


Thanks,

Andi
 
Hello,

We have report this issue to our prodction team and this may be improved in
the next release or service pack. Currently you can choose the work around
as mentioned in your previous message.

Luke
 
Hello,

thanks for the reply, however, I also asked:

"can you please reply to:
Further:
Honestly, I do not see, how:
should help?
What would be the difference in handling the next steps?
It is a problem that now lies with the product group, and why would support
services have a solution any faster (besides of the 48hours newsgroup
response time)?

And: did you forward my "Please take this "policy comment" of the previous
post to the appropriate channel?
"


Regarding your recent post:
You said:
"We have report this issue to our prodction team and this may be improved in
the next release or service pack"
When will there be a Knowledge-Base article (bug/problem or something like
that)?
Will I get a hotfix? I think it is not appropriate to tell the people to
wait for an uncertain amount of time, your reply was a little too "generic".
Referring to wait for a service pack or "next release" for a completely new
product, where it "may be improved" is quite funny. We are talking about the
..NET-framework here, the center of the whole .net-architecture.
I think there should be more direct feedback like:
"Yes, the product team is fixing it"
"Yes, you will be notified and will get a hotfix."

Regards,
 
Hi

If we find a reproduced problem, we will forward it to our dev team for
further research, this is our process.
But I can not guarantee when it will be fixed and when or if the KB will be
published.

Due to the difference support service, the PSS will have a more rapid
response time.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top