当前位置: 首页>>代码示例>>C#>>正文


C# SqlDataRecord.GetSqlValue方法代码示例

本文整理汇总了C#中Microsoft.SqlServer.Server.SqlDataRecord.GetSqlValue方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataRecord.GetSqlValue方法的具体用法?C# SqlDataRecord.GetSqlValue怎么用?C# SqlDataRecord.GetSqlValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SqlServer.Server.SqlDataRecord的用法示例。


在下文中一共展示了SqlDataRecord.GetSqlValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FillCompatibleSettersFromRecord


//.........这里部分代码省略.........
                            SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
                            break;
                        case SqlDbType.Real:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Single));
                            SetSingle_Unchecked(sink, setters, i, record.GetFloat(i));
                            break;
                        case SqlDbType.UniqueIdentifier:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Guid));
                            SetGuid_Unchecked(sink, setters, i, record.GetGuid(i));
                            break;
                        case SqlDbType.SmallDateTime:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
                            SetDateTime_Checked(sink, setters, i, metaData[i], record.GetDateTime(i));
                            break;
                        case SqlDbType.SmallInt:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Int16));
                            SetInt16_Unchecked(sink, setters, i, record.GetInt16(i));
                            break;
                        case SqlDbType.SmallMoney:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlMoney));
                            SetSqlMoney_Checked(sink, setters, i, metaData[i], record.GetSqlMoney(i));
                            break;
                        case SqlDbType.Text:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlChars));
                            SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
                            break;
                        case SqlDbType.Timestamp:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
                            SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                            break;
                        case SqlDbType.TinyInt:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.Byte));
                            SetByte_Unchecked(sink, setters, i, record.GetByte(i));
                            break;
                        case SqlDbType.VarBinary:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
                            SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                            break;
                        case SqlDbType.VarChar:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.String));
                            SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
                            break;
                        case SqlDbType.Xml:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlXml));
                            SetSqlXml_Unchecked(sink, setters, i, record.GetSqlXml(i));    // perf improvement?
                            break;
                        case SqlDbType.Variant:
                            object o = record.GetSqlValue(i);
                            ExtendedClrTypeCode typeCode = MetaDataUtilsSmi.DetermineExtendedTypeCode(o);
                            SetCompatibleValueV200(sink, setters, i, metaData[i], o, typeCode, 0, -1 /* no length restriction */, null /* no peekahead */);
                            break;
                        case SqlDbType.Udt:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.SqlBytes));
                            SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                            break;
                        case SqlDbType.Date:
                        case SqlDbType.DateTime2:
                            Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTime));
                            SetDateTime_Checked(sink, setters, i, metaData[i], record.GetDateTime(i));
                            break;
                        case SqlDbType.Time:
                            { // block to scope sqlReader local and avoid conflicts
                                Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.TimeSpan));
                                SqlDataRecord sqlRecord = record as SqlDataRecord;
                                TimeSpan ts;
                                if (null != sqlRecord)
                                {
                                    ts = sqlRecord.GetTimeSpan(i);
                                }
                                else
                                {
                                    ts = (TimeSpan)record.GetValue(i);
                                }
                                SetTimeSpan_Checked(sink, setters, i, metaData[i], ts);
                            }
                            break;
                        case SqlDbType.DateTimeOffset:
                            { // block to scope sqlReader local and avoid conflicts
                                Debug.Assert(CanAccessSetterDirectly(metaData[i], ExtendedClrTypeCode.DateTimeOffset));
                                SqlDataRecord sqlRecord = record as SqlDataRecord;
                                DateTimeOffset dto;
                                if (null != sqlRecord)
                                {
                                    dto = sqlRecord.GetDateTimeOffset(i);
                                }
                                else
                                {
                                    dto = (DateTimeOffset)record.GetValue(i);
                                }
                                SetDateTimeOffset_Unchecked(sink, setters, i, dto);
                            }
                            break;

                        default:
                            Debug.Assert(false, "unsupported DbType:" + metaData[i].SqlDbType.ToString());
                            throw ADP.NotSupported();
                    }
                }
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:ValueUtilsSmi.cs

示例2: FillCompatibleITypedSettersFromRecord


//.........这里部分代码省略.........
                 continue;
             }
             case SqlDbType.Float:
             {
                 SetDouble_Unchecked(sink, setters, i, record.GetDouble(i));
                 continue;
             }
             case SqlDbType.Image:
             {
                 SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.Int:
             {
                 SetInt32_Unchecked(sink, setters, i, record.GetInt32(i));
                 continue;
             }
             case SqlDbType.Money:
             {
                 SetSqlMoney_Unchecked(sink, setters, i, metaData[i], record.GetSqlMoney(i));
                 continue;
             }
             case SqlDbType.NChar:
             case SqlDbType.NText:
             case SqlDbType.NVarChar:
             {
                 SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.Real:
             {
                 SetSingle_Unchecked(sink, setters, i, record.GetFloat(i));
                 continue;
             }
             case SqlDbType.UniqueIdentifier:
             {
                 SetGuid_Unchecked(sink, setters, i, record.GetGuid(i));
                 continue;
             }
             case SqlDbType.SmallDateTime:
             {
                 SetDateTime_Checked(sink, setters, i, metaData[i], record.GetDateTime(i));
                 continue;
             }
             case SqlDbType.SmallInt:
             {
                 SetInt16_Unchecked(sink, setters, i, record.GetInt16(i));
                 continue;
             }
             case SqlDbType.SmallMoney:
             {
                 SetSqlMoney_Checked(sink, setters, i, metaData[i], record.GetSqlMoney(i));
                 continue;
             }
             case SqlDbType.Text:
             {
                 SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.Timestamp:
             {
                 SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.TinyInt:
             {
                 SetByte_Unchecked(sink, setters, i, record.GetByte(i));
                 continue;
             }
             case SqlDbType.VarBinary:
             {
                 SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.VarChar:
             {
                 SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.Variant:
             {
                 object sqlValue = record.GetSqlValue(i);
                 ExtendedClrTypeCode typeCode = MetaDataUtilsSmi.DetermineExtendedTypeCode(sqlValue);
                 SetCompatibleValue(sink, setters, i, metaData[i], sqlValue, typeCode, 0);
                 continue;
             }
             case SqlDbType.Xml:
             {
                 SetSqlXml_Unchecked(sink, setters, i, record.GetSqlXml(i));
                 continue;
             }
             case SqlDbType.Udt:
             {
                 SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
         }
         throw ADP.NotSupported();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ValueUtilsSmi.cs

示例3: FillCompatibleITypedSettersFromRecord


//.........这里部分代码省略.........
                     SetBytes_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 case SqlDbType.Bit:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Boolean ) );
                     SetBoolean_Unchecked( sink, setters, i, record.GetBoolean(i) );
                     break;
                 case SqlDbType.Char:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
                     SetChars_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 case SqlDbType.DateTime:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.DateTime ) );
                     SetDateTime_Checked( sink, setters, i, metaData[i], record.GetDateTime(i) );
                     break;
                 case SqlDbType.Decimal:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlDecimal ) );
                     SetSqlDecimal_Unchecked( sink, setters, i, record.GetSqlDecimal(i) );
                     break;
                 case SqlDbType.Float:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Double ) );
                     SetDouble_Unchecked( sink, setters, i, record.GetDouble(i) );
                     break;
                 case SqlDbType.Image:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
                     SetBytes_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 case SqlDbType.Int:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int32 ) );
                     SetInt32_Unchecked( sink, setters, i, record.GetInt32(i) );
                     break;
                 case SqlDbType.Money:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlMoney ) );
                     SetSqlMoney_Unchecked( sink, setters, i, metaData[i], record.GetSqlMoney(i) );
                     break;
                 case SqlDbType.NChar:
                 case SqlDbType.NText:
                 case SqlDbType.NVarChar:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
                     SetChars_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 case SqlDbType.Real:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Single ) );
                     SetSingle_Unchecked( sink, setters, i, record.GetFloat(i) );
                     break;
                 case SqlDbType.UniqueIdentifier:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Guid ) );
                     SetGuid_Unchecked( sink, setters, i, record.GetGuid(i) );
                     break;
                 case SqlDbType.SmallDateTime:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.DateTime ) );
                     SetDateTime_Checked( sink, setters, i, metaData[i], record.GetDateTime(i) );
                     break;
                 case SqlDbType.SmallInt:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Int16 ) );
                     SetInt16_Unchecked( sink, setters, i, record.GetInt16(i) );
                     break;
                 case SqlDbType.SmallMoney:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlMoney ) );
                     SetSqlMoney_Checked( sink, setters, i, metaData[i], record.GetSqlMoney(i) );
                     break;
                 case SqlDbType.Text:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlChars ) );
                     SetChars_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 case SqlDbType.Timestamp:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
                     SetBytes_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 case SqlDbType.TinyInt:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.Byte ) );
                     SetByte_Unchecked( sink, setters, i, record.GetByte(i) );
                     break;
                 case SqlDbType.VarBinary:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
                     SetBytes_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 case SqlDbType.VarChar:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.String ) );
                     SetChars_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 case SqlDbType.Xml:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlXml ) );
                     SetSqlXml_Unchecked( sink, setters, i, record.GetSqlXml(i) );    // perf improvement?
                     break;
                 case SqlDbType.Variant:
                     object o = record.GetSqlValue(i);
                     ExtendedClrTypeCode typeCode = MetaDataUtilsSmi.DetermineExtendedTypeCode( o );
                     SetCompatibleValue( sink, setters, i, metaData[i], o, typeCode, 0 );
                     break;
                 case SqlDbType.Udt:
                     Debug.Assert( CanAccessSetterDirectly( metaData[i], ExtendedClrTypeCode.SqlBytes ) );
                     SetBytes_FromRecord( sink, setters, i, metaData[i], record, 0 );
                     break;
                 default:
                     Debug.Assert( false, "unsupported DbType:" + metaData[i].SqlDbType.ToString() );
                     throw ADP.NotSupported();
             }
         }
     }
 }
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:ValueUtilsSmi.cs

示例4: FillCompatibleSettersFromRecord


//.........这里部分代码省略.........
             {
                 SetGuid_Unchecked(sink, setters, i, record.GetGuid(i));
                 continue;
             }
             case SqlDbType.SmallDateTime:
             {
                 SetDateTime_Checked(sink, setters, i, metaData[i], record.GetDateTime(i));
                 continue;
             }
             case SqlDbType.SmallInt:
             {
                 SetInt16_Unchecked(sink, setters, i, record.GetInt16(i));
                 continue;
             }
             case SqlDbType.SmallMoney:
             {
                 SetSqlMoney_Checked(sink, setters, i, metaData[i], record.GetSqlMoney(i));
                 continue;
             }
             case SqlDbType.Text:
             {
                 SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.Timestamp:
             {
                 SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.TinyInt:
             {
                 SetByte_Unchecked(sink, setters, i, record.GetByte(i));
                 continue;
             }
             case SqlDbType.VarBinary:
             {
                 SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.VarChar:
             {
                 SetChars_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.Variant:
             {
                 object sqlValue = record.GetSqlValue(i);
                 ExtendedClrTypeCode typeCode = MetaDataUtilsSmi.DetermineExtendedTypeCode(sqlValue);
                 SetCompatibleValueV200(sink, setters, i, metaData[i], sqlValue, typeCode, 0, -1, null);
                 continue;
             }
             case SqlDbType.Xml:
             {
                 SetSqlXml_Unchecked(sink, setters, i, record.GetSqlXml(i));
                 continue;
             }
             case SqlDbType.Udt:
             {
                 SetBytes_FromRecord(sink, setters, i, metaData[i], record, 0);
                 continue;
             }
             case SqlDbType.Date:
             case SqlDbType.DateTime2:
             {
                 SetDateTime_Checked(sink, setters, i, metaData[i], record.GetDateTime(i));
                 continue;
             }
             case SqlDbType.Time:
             {
                 SqlDataRecord record3 = record;
                 if (record3 == null)
                 {
                     break;
                 }
                 timeSpan = record3.GetTimeSpan(i);
                 goto Label_02EF;
             }
             case SqlDbType.DateTimeOffset:
             {
                 SqlDataRecord record2 = record;
                 if (record2 == null)
                 {
                     goto Label_030C;
                 }
                 dateTimeOffset = record2.GetDateTimeOffset(i);
                 goto Label_0319;
             }
             default:
                 throw ADP.NotSupported();
         }
         timeSpan = (TimeSpan) record.GetValue(i);
     Label_02EF:
         SetTimeSpan_Checked(sink, setters, i, metaData[i], timeSpan);
         continue;
     Label_030C:
         dateTimeOffset = (DateTimeOffset) record.GetValue(i);
     Label_0319:
         SetDateTimeOffset_Unchecked(sink, setters, i, dateTimeOffset);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ValueUtilsSmi.cs


注:本文中的Microsoft.SqlServer.Server.SqlDataRecord.GetSqlValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。