本文整理汇总了C#中System.Data.SqlClient.SqlParameter.ShouldSerializeSqlDbType方法的典型用法代码示例。如果您正苦于以下问题:C# SqlParameter.ShouldSerializeSqlDbType方法的具体用法?C# SqlParameter.ShouldSerializeSqlDbType怎么用?C# SqlParameter.ShouldSerializeSqlDbType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlParameter
的用法示例。
在下文中一共展示了SqlParameter.ShouldSerializeSqlDbType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToInstanceDescriptor
private System.ComponentModel.Design.Serialization.InstanceDescriptor ConvertToInstanceDescriptor(SqlParameter p) {
// MDAC 67321 - reducing parameter generated code
int flags = 0; // if part of the collection - the parametername can't be empty
if (p.ShouldSerializeSqlDbType()) {
flags |= 1;
}
if (p.ShouldSerializeSize()) {
flags |= 2;
}
if (!ADP.IsEmpty(p.SourceColumn)) {
flags |= 4;
}
if (null != p.Value) {
flags |= 8;
}
if ((ParameterDirection.Input != p.Direction) || p.IsNullable
|| p.ShouldSerializePrecision() || p.ShouldSerializeScale()
|| (DataRowVersion.Current != p.SourceVersion)
) {
flags |= 16; // v1.0 everything
}
if (p.SourceColumnNullMapping || !ADP.IsEmpty(p.XmlSchemaCollectionDatabase) ||
!ADP.IsEmpty(p.XmlSchemaCollectionOwningSchema) || !ADP.IsEmpty(p.XmlSchemaCollectionName)) {
flags |= 32; // v2.0 everything
}
Type[] ctorParams;
object[] ctorValues;
switch(flags) {
case 0: // ParameterName
case 1: // SqlDbType
ctorParams = new Type[] { typeof(string), typeof(SqlDbType) };
ctorValues = new object[] { p.ParameterName, p.SqlDbType };
break;
case 2: // Size
case 3: // Size, SqlDbType
ctorParams = new Type[] { typeof(string), typeof(SqlDbType), typeof(int) };
ctorValues = new object[] { p.ParameterName, p.SqlDbType, p.Size };
break;
case 4: // SourceColumn
case 5: // SourceColumn, SqlDbType
case 6: // SourceColumn, Size
case 7: // SourceColumn, Size, SqlDbType
ctorParams = new Type[] { typeof(string), typeof(SqlDbType), typeof(int), typeof(string) };
ctorValues = new object[] { p.ParameterName, p.SqlDbType, p.Size, p.SourceColumn };
break;
case 8: // Value
ctorParams = new Type[] { typeof(string), typeof(object) };
ctorValues = new object[] { p.ParameterName, p.Value };
break;
default:
if (0 == (32 & flags)) { // v1.0 everything
ctorParams = new Type[] {
typeof(string), typeof(SqlDbType), typeof(int), typeof(ParameterDirection),
typeof(bool), typeof(byte), typeof(byte),
typeof(string), typeof(DataRowVersion),
typeof(object) };
ctorValues = new object[] {
p.ParameterName, p.SqlDbType, p.Size, p.Direction,
p.IsNullable, p.PrecisionInternal, p.ScaleInternal,
p.SourceColumn, p.SourceVersion,
p.Value };
}
else { // v2.0 everything - round trip all browsable properties + precision/scale
ctorParams = new Type[] {
typeof(string), typeof(SqlDbType), typeof(int), typeof(ParameterDirection),
typeof(byte), typeof(byte),
typeof(string), typeof(DataRowVersion), typeof(bool),
typeof(object),
typeof(string), typeof(string),
typeof(string) };
ctorValues = new object[] {
p.ParameterName, p.SqlDbType, p.Size, p.Direction,
p.PrecisionInternal, p.ScaleInternal,
p.SourceColumn, p.SourceVersion, p.SourceColumnNullMapping,
p.Value,
p.XmlSchemaCollectionDatabase, p.XmlSchemaCollectionOwningSchema,
p.XmlSchemaCollectionName};
}
break;
}
System.Reflection.ConstructorInfo ctor = typeof(SqlParameter).GetConstructor(ctorParams);
return new System.ComponentModel.Design.Serialization.InstanceDescriptor(ctor, ctorValues);
}
示例2: ConvertToInstanceDescriptor
private InstanceDescriptor ConvertToInstanceDescriptor(SqlParameter p)
{
object[] objArray3;
Type[] typeArray3;
int num = 0;
if (p.ShouldSerializeSqlDbType())
{
num |= 1;
}
if (p.ShouldSerializeSize())
{
num |= 2;
}
if (!ADP.IsEmpty(p.SourceColumn))
{
num |= 4;
}
if (p.Value != null)
{
num |= 8;
}
if (((ParameterDirection.Input != p.Direction) || p.IsNullable) || ((p.ShouldSerializePrecision() || p.ShouldSerializeScale()) || (DataRowVersion.Current != p.SourceVersion)))
{
num |= 0x10;
}
if ((p.SourceColumnNullMapping || !ADP.IsEmpty(p.XmlSchemaCollectionDatabase)) || (!ADP.IsEmpty(p.XmlSchemaCollectionOwningSchema) || !ADP.IsEmpty(p.XmlSchemaCollectionName)))
{
num |= 0x20;
}
switch (num)
{
case 0:
case 1:
typeArray3 = new Type[] { typeof(string), typeof(SqlDbType) };
objArray3 = new object[] { p.ParameterName, p.SqlDbType };
break;
case 2:
case 3:
typeArray3 = new Type[] { typeof(string), typeof(SqlDbType), typeof(int) };
objArray3 = new object[] { p.ParameterName, p.SqlDbType, p.Size };
break;
case 4:
case 5:
case 6:
case 7:
typeArray3 = new Type[] { typeof(string), typeof(SqlDbType), typeof(int), typeof(string) };
objArray3 = new object[] { p.ParameterName, p.SqlDbType, p.Size, p.SourceColumn };
break;
case 8:
typeArray3 = new Type[] { typeof(string), typeof(object) };
objArray3 = new object[] { p.ParameterName, p.Value };
break;
default:
if ((0x20 & num) == 0)
{
typeArray3 = new Type[] { typeof(string), typeof(SqlDbType), typeof(int), typeof(ParameterDirection), typeof(bool), typeof(byte), typeof(byte), typeof(string), typeof(DataRowVersion), typeof(object) };
objArray3 = new object[] { p.ParameterName, p.SqlDbType, p.Size, p.Direction, p.IsNullable, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn, p.SourceVersion, p.Value };
}
else
{
typeArray3 = new Type[] { typeof(string), typeof(SqlDbType), typeof(int), typeof(ParameterDirection), typeof(byte), typeof(byte), typeof(string), typeof(DataRowVersion), typeof(bool), typeof(object), typeof(string), typeof(string), typeof(string) };
objArray3 = new object[] { p.ParameterName, p.SqlDbType, p.Size, p.Direction, p.PrecisionInternal, p.ScaleInternal, p.SourceColumn, p.SourceVersion, p.SourceColumnNullMapping, p.Value, p.XmlSchemaCollectionDatabase, p.XmlSchemaCollectionOwningSchema, p.XmlSchemaCollectionName };
}
break;
}
return new InstanceDescriptor(typeof(SqlParameter).GetConstructor(typeArray3), objArray3);
}