本文整理汇总了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;
}
示例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 ();
}