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


C# SqlDataReader.GetSqlInt32方法代码示例

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


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

示例1: DeserializeEvents

        private EventStream DeserializeEvents(Guid id, SqlDataReader result)
        {
            var lastVersion = 0;
            var snapshotVersion = 0;
            var eventTypeIdColumnId = result.GetOrdinal("EventTypeId");
            var eventDataColumnId = result.GetOrdinal("EventData");
            var versionColumnId = result.GetOrdinal("Version");
            var snapshotVersionColumnId = result.GetOrdinal("SnapshotVersion");
            var events = new List<object>();
            while (result.Read())
            {
                var eventTypeId = result.GetSqlGuid(eventTypeIdColumnId).Value;
                lastVersion = result.GetSqlInt32(versionColumnId).Value;
                snapshotVersion = result.GetSqlInt32(snapshotVersionColumnId).Value;
                events.Add(this.serializationMethod.Deserialize(new XmlSerializedData(eventTypeId, result.GetSqlXml(eventDataColumnId).CreateReader())));
            }

            return new EventStream(id, lastVersion, snapshotVersion, events);
        }
开发者ID:TheSoftweyrGroup,项目名称:Softweyr.EventStore,代码行数:19,代码来源:SqlServer2008PersistenceSession.cs

示例2: 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

示例3: GetInt32Test

		public void GetInt32Test ()
		{
			if (ClientVersion == 7)
				cmd.CommandText = string.Format (query, "int", "int", "decimal1");
			else
				cmd.CommandText = string.Format (query, "int", "int", "bigint");

			reader = cmd.ExecuteReader ();
			reader.Read ();
			// Test for standard exceptions 
			GetMethodTests("Int32");

			// Test if data is returned correctly
			Assert.AreEqual (numericRow["type_int"], reader.GetInt32(0),
				"#2 DataValidation Failed");

			// Test for standard exceptions 
			GetMethodTests("SqlInt32");

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


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