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


C# SqlDataRecord.SetFloat方法代码示例

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


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

示例1: CreateFractalRecord

        private static SqlDataRecord CreateFractalRecord(float? value)
        {
            var record = new SqlDataRecord(new SqlMetaData("Value", SqlDbType.Real));

            if (value.HasValue)
                record.SetFloat(0, value.Value);
            else
                record.SetDBNull(0);

            return record;
        }
开发者ID:ovuncgursoy,项目名称:SisoDb-Provider,代码行数:11,代码来源:SqlServerTableParams.cs

示例2: SetValue


//.........这里部分代码省略.........
         case SqlDbType.VarBinary:
             var bytes = value as byte[];
             if (bytes == null)
             {
                 throw new Exception("Value is not byte array");
             }
             sqlDataRecord.SetBytes(ordinal, 0, bytes, 0, bytes.Length);
             break;
         case SqlDbType.Int:
             var integer = value as int?;
             if (integer == null)
             {
                 var ushortValue = (value as ushort?);
                 if (ushortValue == null)
                 {
                     throw new Exception("Value is not int or ushort");
                 }
                 integer = ushortValue.Value;
             }
             sqlDataRecord.SetInt32(ordinal, integer.Value);
             break;
         case SqlDbType.NText:
         case SqlDbType.NVarChar:
         case SqlDbType.VarChar:
         case SqlDbType.Text:
         case SqlDbType.Xml:
             var str = value as string;
             if (str == null)
             {
                 var chars = value as char[];
                 if (chars == null)
                 {
                     throw new Exception("Value is not string or char array");
                 }
                 str = new string(chars);
             }
             sqlDataRecord.SetString(ordinal, str);
             break;
         case SqlDbType.Real:
             var f = value as float?;
             if (f == null)
             {
                 throw new Exception("Value is not float");
             }
             sqlDataRecord.SetFloat(ordinal, f.Value);
             break;
         case SqlDbType.UniqueIdentifier:
             var guid = value as Guid?;
             if (guid == null)
             {
                 throw new Exception("Value is not Guid");
             }
             sqlDataRecord.SetGuid(ordinal, guid.Value);
             break;
         case SqlDbType.SmallInt:
             var sh = value as short?;
             if (sh == null)
             {
                 var uByte = value as sbyte?;
                 if (uByte == null)
                 {
                     throw new Exception("Value is not short or sbyte");
                 }
                 sh = uByte.Value;
             }
             sqlDataRecord.SetInt16(ordinal, sh.Value);
             break;
         case SqlDbType.TinyInt:
             var b = value as byte?;
             if (b == null)
             {
                 throw new Exception("Value is not byte");
             }
             sqlDataRecord.SetByte(ordinal, b.Value);
             break;
         case SqlDbType.Time:
             var timeSpan = value as TimeSpan?;
             if (timeSpan == null)
             {
                 throw new Exception("Value is not TimeSpan");
             }
             sqlDataRecord.SetTimeSpan(ordinal, timeSpan.Value);
             break;
         case SqlDbType.DateTimeOffset:
             var dateTimeOffset = value as DateTimeOffset?;
             if (dateTimeOffset == null)
             {
                 throw new Exception("Value is not DateTimeOffset");
             }
             sqlDataRecord.SetDateTimeOffset(ordinal, dateTimeOffset.Value);
             break;
         case SqlDbType.Structured:
         case SqlDbType.Udt:
         case SqlDbType.Timestamp:
         case SqlDbType.Variant:
             throw new NotImplementedException();
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
开发者ID:riberk,项目名称:CommonCC,代码行数:101,代码来源:SqlRecordSetValue.cs


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