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


C# SqlTypes.SqlInt16类代码示例

本文整理汇总了C#中System.Data.SqlTypes.SqlInt16的典型用法代码示例。如果您正苦于以下问题:C# SqlInt16类的具体用法?C# SqlInt16怎么用?C# SqlInt16使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlInt16类属于System.Data.SqlTypes命名空间,在下文中一共展示了SqlInt16类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MergePHkeys

 public static SqlBinary MergePHkeys(SqlBinary oldPHkeys, SqlInt16 newSnap, SqlInt32 newPHkey)
 {
     SqlIntArray keyArray = new SqlIntArray(oldPHkeys);
     int[] keys = keyArray.ToArray();
     keys[(short) newSnap] = (int) newPHkey;
     return SqlIntArray.FromArray(keys).ToSqlBuffer();
 }
开发者ID:dcrankshaw,项目名称:GadgetLoader,代码行数:7,代码来源:MergeReverseIndex.cs

示例2: Box

 // non-generic methods to extract the value of a nullable type and box it
 public static object Box(SqlInt16 a)
 {
     if (a.IsNull)
         return null;
     else
         return a.Value;
 }
开发者ID:valery-shinkevich,项目名称:sooda,代码行数:8,代码来源:SoodaNullable.cs

示例3: ArithmeticMethods

		public void ArithmeticMethods ()
		{
			SqlInt16 Test64 = new SqlInt16 (64);
			SqlInt16 Test0 = new SqlInt16 (0);
			SqlInt16 Test164 = new SqlInt16 (164);
			SqlInt16 TestMax = new SqlInt16 (SqlInt16.MaxValue.Value);

			// Add()
			Assert.AreEqual ((short) 64, SqlInt16.Add (Test64, Test0).Value, "Test#1");
			Assert.AreEqual ((short) 228, SqlInt16.Add (Test64, Test164).Value, "Test#2");
			Assert.AreEqual ((short) 164, SqlInt16.Add (Test0, Test164).Value, "Test#3");
			Assert.AreEqual ((short) SqlInt16.MaxValue, SqlInt16.Add (TestMax, Test0).Value, "Test#4");

			try {
				SqlInt16.Add (TestMax, Test64);
				Assert.Fail ("Test#5");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#6");
			}

			// Divide()
			Assert.AreEqual ((short) 2, SqlInt16.Divide (Test164, Test64).Value, "Test#7");
			Assert.AreEqual ((short) 0, SqlInt16.Divide (Test64, Test164).Value, "Test#8");
			try {
				SqlInt16.Divide (Test64, Test0);
				Assert.Fail ("Test#9");
			} catch (DivideByZeroException e) {
				Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "Test#10");
			}

			// Mod()
			Assert.AreEqual ((SqlInt16) 36, SqlInt16.Mod (Test164, Test64), "Test#11");
			Assert.AreEqual ((SqlInt16) 64, SqlInt16.Mod (Test64, Test164), "Test#12");

			// Multiply()
			Assert.AreEqual ((short) 10496, SqlInt16.Multiply (Test64, Test164).Value, "Test#13");
			Assert.AreEqual ((short) 0, SqlInt16.Multiply (Test64, Test0).Value, "Test#14");

			try {
				SqlInt16.Multiply (TestMax, Test64);
				Assert.Fail ("Test#15");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#16");
			}

			// Subtract()
			Assert.AreEqual ((short) 100, SqlInt16.Subtract (Test164, Test64).Value, "Test#17");

			try {
				SqlInt16.Subtract (SqlInt16.MinValue, Test164);
				Assert.Fail ("Test#18");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#19");
			}

			// Modulus ()
			Assert.AreEqual ((SqlInt16)36, SqlInt16.Modulus (Test164, Test64), "Test#20");
			Assert.AreEqual ((SqlInt16)64, SqlInt16.Modulus (Test64, Test164), "Test#21");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:59,代码来源:SqlInt16Test.cs

示例4: FindPHkeysAndSlots

    public static IEnumerable FindPHkeysAndSlots(SqlInt16 partsnap, SqlInt16 fofsnap, SqlString temp_partid_table_name, SqlInt32 numparts)
    {
        //string temp_partid_table = "#temp_partid_list";
        List<PhkeySlot> keysAndSlots = new List<PhkeySlot>();
        using (SqlConnection connection = new SqlConnection("context connection=true"))
        {
            connection.Open();
            string getFoFGroupIDsCommandString = "select partid from " + temp_partid_table_name.ToString();
            SqlCommand getFoFGroupIDsListCommand = new SqlCommand(getFoFGroupIDsCommandString, connection);
            SqlDataReader getFOFGroupIDsReader = getFoFGroupIDsListCommand.ExecuteReader();
            Int64[] partids = new Int64[(int) numparts];
            int numlines = 0;
            while (getFOFGroupIDsReader.Read())
            {
                partids[numlines] = Int64.Parse(getFOFGroupIDsReader["partid"].ToString());
                ++numlines;
            }
            getFOFGroupIDsReader.Close();
            // Find the index blocks we need to look in
            HashSet<Int64> blocks = new HashSet<Int64>();
            foreach (Int64 id in partids)
            {
                blocks.Add((id - 1) / 1024 / 1024);
            }

            //means we want all snaps
            string rawCommand = "";
            if (partsnap < 0)
            {
                rawCommand = "select a.snap, a.phkey, a.slot from particleDB.dbo.index{0} a, " + temp_partid_table_name.ToString() + " b "
                    + " where a.partid = b.partid";
            }
            else
            {
                rawCommand = "select a.snap, a.phkey, a.slot from particleDB.dbo.index{0} a, " + temp_partid_table_name.ToString() + " b "
                    + " where a.partid = b.partid and a.snap = @partsnap";
            }

            foreach (Int64 blockID in blocks)
            {
                string joinFoFGroupIndexCommandString = string.Format(rawCommand, blockID);
                SqlCommand joinFofGroupIndexCommand = new SqlCommand(joinFoFGroupIndexCommandString, connection);
                SqlParameter partsnapParam = new SqlParameter("@partsnap", System.Data.SqlDbType.SmallInt);
                partsnapParam.Value = partsnap;
                joinFofGroupIndexCommand.Parameters.Add(partsnapParam);
                SqlDataReader joinReader = joinFofGroupIndexCommand.ExecuteReader();
                while (joinReader.Read())
                {
                    int snap = Int32.Parse(joinReader["snap"].ToString());
                    int phkey = Int32.Parse(joinReader["phkey"].ToString());
                    short slot = Int16.Parse(joinReader["slot"].ToString());
                    PhkeySlot current = new PhkeySlot(snap, phkey, slot);
                    keysAndSlots.Add(current);
                }
                joinReader.Close();
            }
        }
        return keysAndSlots;
    }
开发者ID:dcrankshaw,项目名称:GadgetLoader,代码行数:59,代码来源:IndexLookup.cs

示例5: MergeSlots

 public static SqlBinary MergeSlots(SqlBinary oldSlots, SqlInt16 newSnap, SqlInt16 newSlot)
 {
     //short[] slots = oldSlots.ToArray();
     SqlSmallIntArray slotArray = new SqlSmallIntArray(oldSlots);
     short[] slots = slotArray.ToArray();
     slots[(short) newSnap] = (short) newSlot;
     return SqlSmallIntArray.FromArray(slots).ToSqlBuffer();
 }
开发者ID:dcrankshaw,项目名称:GadgetLoader,代码行数:8,代码来源:MergeReverseIndex.cs

示例6: Properties

 public void Properties()
 {
         SqlInt16 Test5443 = new SqlInt16 (5443);
         SqlInt16 Test1 = new SqlInt16 (1);
         Assert ("Test#1", SqlInt16.Null.IsNull);
         AssertEquals ("Test#2", (short)5443, Test5443.Value);
         AssertEquals ("Test#3", (short)1, Test1.Value);
 }
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:SqlInt16Test.cs

示例7: Properties

		public void Properties ()
		{
			SqlInt16 Test5443 = new SqlInt16 (5443);
			SqlInt16 Test1 = new SqlInt16 (1);
			Assert.IsTrue (SqlInt16.Null.IsNull, "Test#1");
			Assert.AreEqual ((short) 5443, Test5443.Value, "Test#2");
			Assert.AreEqual ((short) 1, Test1.Value, "Test#3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:SqlInt16Test.cs

示例8: Create

		public void Create ()
		{
			SqlInt16 TestShort = new SqlInt16 (29);
			Assert.AreEqual ((short) 29, TestShort.Value, "Test#1");

			TestShort = new SqlInt16 (-9000);
			Assert.AreEqual ((short) -9000, TestShort.Value, "Test#2");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:SqlInt16Test.cs

示例9: Create

                public void Create()
                {
                        SqlInt16 TestShort = new SqlInt16 (29);
                        AssertEquals ("Test#1", (short)29, TestShort.Value);

                        TestShort = new SqlInt16 (-9000);
                        AssertEquals ("Test#2", (short)-9000, TestShort.Value);
                }
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:SqlInt16Test.cs

示例10: Properties

 public void Properties()
 {
     SqlInt16 Test5443 = new SqlInt16(5443);
     SqlInt16 Test1 = new SqlInt16(1);
     Assert.True(SqlInt16.Null.IsNull);
     Assert.Equal((short)5443, Test5443.Value);
     Assert.Equal((short)1, Test1.Value);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:SqlInt16Test.cs

示例11: AddToFilterFillRow

    public static void AddToFilterFillRow(Object obj, out SqlInt16 snap, out SqlInt32 outPHKey, out SqlBinary finalFilter, out SqlInt32 hashFunctions, out SqlInt32 expectedCap)
    {
        object[] row = (object[])obj;
            finalFilter = new SqlBinary((byte[])row[2]);
            snap = new SqlInt16((short) row[0]);// (SqlInt16)row[10];
            outPHKey = new SqlInt32((int) row[1]);

            hashFunctions = new SqlInt32((int)row[3]);
            expectedCap = new SqlInt32((int)row[4]);
    }
开发者ID:dcrankshaw,项目名称:GadgetLoader,代码行数:10,代码来源:FilterUDFs.cs

示例12: RegexMatch

    public static SqlString RegexMatch(SqlString text, SqlString pattern, SqlInt16 groupIndex)
    {
        var patternValue = pattern.IsNull ? null : pattern.Value;
        if (patternValue == null)
            throw new ArgumentNullException("pattern");

        var textValue = text.IsNull ? null : text.Value;
        if (textValue == null) return SqlString.Null;

        var groupIndexValue = groupIndex.IsNull ? 0 : groupIndex.Value;

        var match = Regex.Match(text.Value, pattern.Value, RegexOptions.Compiled /*| RegexOptions.IgnoreCase*/);
        if (!match.Success) return SqlString.Null;

        var group = match.Groups[groupIndexValue];
        if (!group.Success) return SqlString.Null;

        return new SqlString(group.Value, text.LCID);
    }
开发者ID:raziqyork,项目名称:Geeks.SqlUtils,代码行数:19,代码来源:Regex.cs

示例13: Accumulate

    public void Accumulate(SqlDouble value, SqlInt16 percentile)
    {
        // Put your code here
        if (value.IsNull != true)
        {
            doubleList.Add(value.Value);
        }

        if (percentile.IsNull != true)
        {
            if (percentile.Value > 100)
            {
                this.percentile = 100;
            }
            else
            {
                this.percentile = percentile.Value;
            }
        }
    }
开发者ID:JustinRoll,项目名称:SqlServerUtilities,代码行数:20,代码来源:Percentile.cs

示例14: SetSqlInt16

        internal static void SetSqlInt16( SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SmiMetaData metaData, SqlInt16 value ) {
            ThrowIfInvalidSetterAccess( metaData, ExtendedClrTypeCode.SqlInt16 );

            SetSqlInt16_Unchecked( sink, setters, ordinal, value ); 
        }
开发者ID:uQr,项目名称:referencesource,代码行数:5,代码来源:ValueUtilsSmi.cs

示例15: ReadValues

        private Boolean ReadValues(System.IO.BinaryReader r)
        {
            Int32 count;
              if(r.BaseStream.Length == 0) return false;
              count = Sql.Read7BitEncodedInt(r);

              if (count == 0) return true;

              for (Int32 i = 0; i < count; i++)
              {
            String    name  = r.ReadString();
            SqlDbType LType = (SqlDbType)r.ReadUInt16();
            Object    value = null;
            Int32 len;
            //Int32 lcid;
            //SqlCompareOptions co;

            switch (LType)
            {
              case SqlDbType.Bit      : value = new SqlBoolean(r.ReadBoolean()); break;
              case SqlDbType.TinyInt  : value = new SqlByte(r.ReadByte()); break;
              case SqlDbType.SmallInt : value = new SqlInt16((Int16)r.ReadInt16()); break;
              case SqlDbType.Int      : value = new SqlInt32((Int32)r.ReadInt32()); break;
              case SqlDbType.BigInt   : value = new SqlInt64(r.ReadInt64()); break;

              case SqlDbType.Binary   :
              case SqlDbType.VarBinary: len = r.ReadUInt16(); value = new SqlBytes(r.ReadBytes(len)); break;

              case SqlDbType.Char     :
              case SqlDbType.VarChar  : //value = new Sql.SqlAnsiString(r); break;
              case SqlDbType.NChar:
              case SqlDbType.NVarChar:
            //co = (SqlCompareOptions)r.ReadUInt16();
            //lcid = r.ReadInt32();
            //value = new SqlString(r.ReadString(), lcid, co);
            value = new SqlString(r.ReadString());
            break;

              case SqlDbType.DateTime     : value = new SqlDateTime(DateTime.FromBinary(r.ReadInt64())); break;
              case SqlDbType.SmallDateTime:
              case SqlDbType.Date         :
              case SqlDbType.DateTime2    : value = DateTime.FromBinary(r.ReadInt64()); break;
              case SqlDbType.Time         : value = TimeSpan.FromTicks(r.ReadInt64()); break;
              case SqlDbType.DateTimeOffset:
            DateTime LDateTime = DateTime.FromBinary(r.ReadInt64());
            value = new DateTimeOffset(LDateTime, TimeSpan.FromTicks(r.ReadInt64()));
            break;

              case SqlDbType.Decimal: value = new SqlDecimal(r.ReadDecimal()); break;
              case SqlDbType.Float  : value = new SqlDouble(r.ReadDouble()); break;
              // Not support SqlDbType.Image
              case SqlDbType.Money  : value = new SqlMoney(r.ReadDecimal()); break;
              case SqlDbType.Real   : value = new SqlSingle(r.ReadDouble()); break;
              case SqlDbType.SmallMoney: value = new SqlMoney(r.ReadDecimal()); break;
              // Not support SqlDbType.Structured
              // Not support SqlDbType.Text
              // Not support SqlDbType.Timestamp
              case SqlDbType.UniqueIdentifier: value = new SqlGuid(r.ReadString()); break;
              // Not support SqlDbType.Variant
              case SqlDbType.Xml:
            XmlReader rXml = XmlReader.Create(new System.IO.StringReader(r.ReadString()));
            value = new SqlXml(rXml);
            break;

              case SqlDbType.Udt:
            // TODO: Пока поддержа только TParams
            //String LTypeName = r.ReadString();
            //value = CreateUdtObject(LTypeName);
            //if (value is IBinarySerialize)
            //  (value as IBinarySerialize).Read(r);
            //else
            //  throw new Exception(String.Format("Невозможно прочитать данные типа UDT '{0}' - не поддерживается IBinarySerialize", LTypeName));
            value = new SqlUdt(r);
            break;

              default:
            throw new Exception(String.Format("Невозможно прочитать данные, тип '{0}' не поддерживается текущей версией {1}", LType.ToString(), this.GetType().Name));
              // Not support SqlDbType.NText
            }
            if (value != null) FData.Add(name, value);
              }

              return true;
        }
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:84,代码来源:TParams.cs


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