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


C# SqlDataReader.GetSqlBoolean方法代码示例

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


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

示例1: ConvertFromRow

        private static MembershipEntry ConvertFromRow(SqlDataReader results, out string eTag, out int tableVersion, out string versionETag)
        {
            var entry = new MembershipEntry();

            int port = results.GetInt32(PortIdx);
            int gen = results.GetInt32(GenerationIdx);
            entry.SiloAddress = SiloAddress.New(new IPEndPoint(IPAddress.Parse(results.GetString(AddressIdx)), port), gen);

            entry.HostName = results.GetString(HostNameIdx);
            entry.Status = (SiloStatus)results.GetInt32(StatusIdx);
            if (!results.GetSqlInt32(ProxyPortIdx).IsNull)
                entry.ProxyPort = results.GetInt32(ProxyPortIdx);
            if (!results.GetSqlBoolean(PrimaryIdx).IsNull)
                entry.IsPrimary = results.GetBoolean(PrimaryIdx);

            entry.RoleName = results.GetString(RoleNameIdx);
            entry.InstanceName = results.GetString(InstanceNameIdx);
            if (!results.GetSqlInt32(UpdateZoneIdx).IsNull)
                entry.UpdateZone = results.GetInt32(UpdateZoneIdx);
            if (!results.GetSqlInt32(FaultZoneIdx).IsNull)
                entry.FaultZone = results.GetInt32(FaultZoneIdx);

            if (!results.GetSqlDateTime(StartTimeIdx).IsNull)
                entry.StartTime = results.GetDateTime(StartTimeIdx);
            if (!results.GetSqlDateTime(IAmAliveTimeIdx).IsNull)
                entry.IAmAliveTime = results.GetDateTime(IAmAliveTimeIdx);
            eTag = results.GetString(ETagIdx);
            tableVersion = (int)results.GetInt64(VersionIdx);
            versionETag = results.GetString(VersionETagIdx);

            var suspectingSilosString = results.GetSqlString(SuspectingSilosIdx);
            var suspectingTimesString = results.GetSqlString(SuspectingTimesIdx);

            List<SiloAddress> suspectingSilos = new List<SiloAddress>();
            List<DateTime> suspectingTimes = new List<DateTime>();
            if (!suspectingSilosString.IsNull && !string.IsNullOrEmpty(suspectingSilosString.Value))
            {
                string[] silos = suspectingSilosString.Value.Split('|');
                foreach (string silo in silos)
                {
                    suspectingSilos.Add(SiloAddress.FromParsableString(silo));
                }
            }

            if (!suspectingTimesString.IsNull && !string.IsNullOrEmpty(suspectingTimesString.Value))
            {
                string[] times = suspectingTimesString.Value.Split('|');
                foreach (string time in times)
                {
                    suspectingTimes.Add(TraceLogger.ParseDate(time));
                }
            }

            if (suspectingSilos.Count != suspectingTimes.Count)
                throw new OrleansException(String.Format("SuspectingSilos.Length of {0} as read from SQL table is not eqaul to SuspectingTimes.Length of {1}", suspectingSilos.Count, suspectingTimes.Count));

            for (int i = 0; i < suspectingSilos.Count; i++)
            {
                entry.AddSuspector(suspectingSilos[i], suspectingTimes[i]);
            }
            return entry;
        }
开发者ID:stanroze,项目名称:orleans,代码行数:62,代码来源:SqlMembershipTable.cs

示例2: GetBooleanTest

		public void GetBooleanTest ()
		{
			cmd.CommandText = string.Format (query, "bit", "bit", "int");
			reader = cmd.ExecuteReader ();
			reader.Read ();
			// Test for standard exceptions 
			GetMethodTests("Boolean");

			// Test if data is returned correctly
			Assert.AreEqual (numericRow ["type_bit"], reader.GetBoolean (0),
						"#2 DataValidation Failed");
			
			// Test for standard exceptions 
			GetMethodTests("SqlBoolean");

			// Test if data is returned correctly
			Assert.AreEqual (numericRow["type_bit"], reader.GetSqlBoolean(0).Value,
				"#4 DataValidation Failed");	
			reader.Close ();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:20,代码来源:SqlDataReaderTest.cs


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