本文整理汇总了C#中IDataReader.GetDouble方法的典型用法代码示例。如果您正苦于以下问题:C# IDataReader.GetDouble方法的具体用法?C# IDataReader.GetDouble怎么用?C# IDataReader.GetDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataReader
的用法示例。
在下文中一共展示了IDataReader.GetDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDouble
public static double GetDouble(IDataReader dr, string columnName)
{
int ordinal = dr.GetOrdinal(columnName);
bool isDbNull = dr.IsDBNull(ordinal);
return isDbNull ? double.NaN : dr.GetDouble(ordinal);
}
示例2: GetDoubleNullCheck
public static double GetDoubleNullCheck(IDataReader reader, int ordinal)
{
try {
return reader.IsDBNull(ordinal) ? 0 : reader.GetFieldType(ordinal).Name == "Double" ? reader.GetDouble(ordinal) : Convert.ToDouble(reader.GetString(ordinal));
} catch (Exception) {
return 0;
}
}
示例3: GetValueByIndex
/// <summary>
/// Gets a column value by the index
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
{
if (dataReader.IsDBNull(mapping.ColumnIndex))
{
return DBNull.Value;
}
return dataReader.GetDouble(mapping.ColumnIndex);
}
示例4: GetValueByName
/// <summary>
/// Gets a column value by the name
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
{
int index = dataReader.GetOrdinal(mapping.ColumnName);
if (dataReader.IsDBNull(index))
{
return DBNull.Value;
}
return new double?(dataReader.GetDouble(index));
}
示例5: GetDouble
public static bool GetDouble(IDataReader reader, int nColumn, out double val)
{
try
{
val = reader.GetDouble(nColumn);
return true;
}
catch (Exception)
{
val = double.NaN;
return false;
}
}
示例6: GetDouble
public double GetDouble(IDataReader row, string field)
{
try
{
var i = GetField(row, field);
if (row.IsDBNull(i)) return 0d;
return row.GetDouble(i);
}
catch (Exception ex)
{
throw new Exception("BindingError: " + field, ex);
}
}
示例7: DataReaderToList
private IList<Venue> DataReaderToList(IDataReader reader)
{
var venues = new List<Venue>();
while (reader.Read())
{
venues.Add(new Venue((int)reader.GetInt32(0),
(string)reader.GetString(1),
(int)reader.GetInt32(2),
new Location((string)reader.GetString(3), (string)reader.GetString(4)),
(double)reader.GetDouble(5),
(double)reader.GetDouble(6)
));
}
return venues;
}
示例8: GetValueByName
/// <summary>
/// Gets a column value by the name
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByName(ResultProperty mapping, IDataReader dataReader)
{
int index = dataReader.GetOrdinal(mapping.ColumnName);
if (dataReader.IsDBNull(index) == true)
{
return System.DBNull.Value;
}
else
{
return dataReader.GetDouble(index);
}
}
示例9: LerAtributos
protected virtual void LerAtributos(IDataReader leitor, int inicioAtributo)
{
codigo = (ulong)leitor.GetInt64(inicioAtributo);
nome = leitor.GetString(inicioAtributo + 1);
if (!leitor.IsDBNull(inicioAtributo + 2))
setor = Setor.ObterSetor((uint)leitor.GetInt16(inicioAtributo + 2));
if (leitor[inicioAtributo + 3] != DBNull.Value)
email = leitor.GetString(inicioAtributo + 3);
if (leitor[inicioAtributo + 4] != DBNull.Value)
observações = leitor.GetString(inicioAtributo + 4);
if (leitor[inicioAtributo + 5] != DBNull.Value)
últimaVisita = leitor.GetDateTime(inicioAtributo + 5);
if (leitor[inicioAtributo + 6] != DBNull.Value)
dataRegistro = leitor.GetDateTime(inicioAtributo + 6);
if (leitor[inicioAtributo + 7] != DBNull.Value)
dataAlteração = leitor.GetDateTime(inicioAtributo + 7);
classificações = (ulong)leitor.GetInt64(inicioAtributo + 8);
if (leitor[inicioAtributo + 9] != DBNull.Value)
maiorVenda = leitor.GetDouble(inicioAtributo + 9);
if (leitor[inicioAtributo + 10] != DBNull.Value)
crédito = leitor.GetDouble(inicioAtributo + 10);
if (leitor[inicioAtributo + 11] != DBNull.Value)
região = Região.ObterRegião((uint)leitor[inicioAtributo + 11]);
}
示例10: GetDouble
public double GetDouble(IDataReader reader, double nullValue)
{
InitColumn(reader);
if (reader.IsDBNull(Ordinal))
{
return nullValue;
}
else
{
return reader.GetDouble(Ordinal);
}
}
示例11: DecodeExecutorFromDataReader
private ExecutorStorageView[] DecodeExecutorFromDataReader(IDataReader dataReader)
{
ArrayList executors = new ArrayList();
using(dataReader)
{
while(dataReader.Read())
{
// in SQL the executor ID is stored as a GUID so we use GetValue instead of GetString in order to maximize compatibility with other databases
string executorId = dataReader.GetValue(dataReader.GetOrdinal("executor_id")).ToString();
bool dedicated = dataReader.GetBoolean(dataReader.GetOrdinal("is_dedicated"));
bool connected = dataReader.GetBoolean(dataReader.GetOrdinal("is_connected"));
DateTime pingTime = GetDateTime(dataReader, "ping_time");
string hostname = dataReader.GetString(dataReader.GetOrdinal("host"));
int port = dataReader.IsDBNull(dataReader.GetOrdinal("port")) ? 0 : dataReader.GetInt32(dataReader.GetOrdinal("port"));
string username = dataReader.GetString(dataReader.GetOrdinal("usr_name"));
int maxCpu = dataReader.IsDBNull(dataReader.GetOrdinal("cpu_max")) ? 0 : dataReader.GetInt32(dataReader.GetOrdinal("cpu_max"));
int cpuUsage = dataReader.IsDBNull(dataReader.GetOrdinal("cpu_usage")) ? 0 : dataReader.GetInt32(dataReader.GetOrdinal("cpu_usage"));
int availableCpu = dataReader.IsDBNull(dataReader.GetOrdinal("cpu_avail")) ? 0 : dataReader.GetInt32(dataReader.GetOrdinal("cpu_avail"));
float totalCpuUsage = dataReader.IsDBNull(dataReader.GetOrdinal("cpu_totalusage")) ? 0 : (float)dataReader.GetDouble(dataReader.GetOrdinal("cpu_totalusage"));
float maxMemory = dataReader.IsDBNull(dataReader.GetOrdinal("mem_max")) ? 0 : (float)dataReader.GetDouble(dataReader.GetOrdinal("mem_max"));;
float maxDisk = dataReader.IsDBNull(dataReader.GetOrdinal("disk_max")) ? 0 : (float)dataReader.GetDouble(dataReader.GetOrdinal("disk_max"));
int numberOfCpu = dataReader.IsDBNull(dataReader.GetOrdinal("num_cpus")) ? 0 : dataReader.GetInt32(dataReader.GetOrdinal("num_cpus"));
string os = dataReader.IsDBNull(dataReader.GetOrdinal("os")) ? "" : dataReader.GetString(dataReader.GetOrdinal("os"));
string architecture = dataReader.IsDBNull(dataReader.GetOrdinal("arch")) ? "" : dataReader.GetString(dataReader.GetOrdinal("arch"));
ExecutorStorageView executor = new ExecutorStorageView(
executorId,
dedicated,
connected,
pingTime,
hostname,
port,
username,
maxCpu,
cpuUsage,
availableCpu,
totalCpuUsage,
maxMemory,
maxDisk,
numberOfCpu,
os,
architecture
);
executors.Add(executor);
}
dataReader.Close();
}
return (ExecutorStorageView[])executors.ToArray(typeof(ExecutorStorageView));
}
示例12: GetJob
private SyncJob GetJob(IDataReader reader)
{
var info = new SyncJob
{
Id = reader.GetGuid(0).ToString("N"),
TargetId = reader.GetString(1),
Name = reader.GetString(2)
};
if (!reader.IsDBNull(3))
{
info.Quality = (SyncQuality)Enum.Parse(typeof(SyncQuality), reader.GetString(3), true);
}
if (!reader.IsDBNull(4))
{
info.Status = (SyncJobStatus)Enum.Parse(typeof(SyncJobStatus), reader.GetString(4), true);
}
if (!reader.IsDBNull(5))
{
info.Progress = reader.GetDouble(5);
}
if (!reader.IsDBNull(6))
{
info.UserId = reader.GetString(6);
}
if (!reader.IsDBNull(7))
{
info.RequestedItemIds = reader.GetString(7).Split(',').ToList();
}
if (!reader.IsDBNull(8))
{
info.UnwatchedOnly = reader.GetBoolean(8);
}
if (!reader.IsDBNull(9))
{
info.Limit = reader.GetInt64(9);
}
if (!reader.IsDBNull(10))
{
info.LimitType = (SyncLimitType)Enum.Parse(typeof(SyncLimitType), reader.GetString(10), true);
}
info.IsDynamic = reader.GetBoolean(11);
info.DateCreated = reader.GetDateTime(12).ToUniversalTime();
info.DateLastModified = reader.GetDateTime(13).ToUniversalTime();
info.ItemCount = reader.GetInt32(14);
return info;
}
示例13: PreencherAtributos
protected override void PreencherAtributos(IDataReader leitor, int inicioAtributosPagamento, int inicioAtributosEspecifico)
{
base.PreencherAtributos(leitor, inicioAtributosPagamento, inicioAtributosEspecifico);
peso = leitor.GetDouble(inicioAtributosEspecifico + 1);
paraFundir = leitor.GetBoolean(inicioAtributosEspecifico + 2);
multiplicador = leitor.GetDouble(inicioAtributosEspecifico + 3);
cotacao = leitor.GetDouble(inicioAtributosEspecifico + 4);
}
示例14: ConvertToPrice
private Price ConvertToPrice(IDataReader reader)
{
return new Price
{
Id = reader.GetGuid(reader.GetOrdinal("GUID_RECORD")),
ProductId = reader.GetGuid(reader.GetOrdinal("ITEM_GUID")),
ProductPrice = reader.GetDouble(reader.GetOrdinal("PRICE")),
};
}
示例15: ReadRow
/// <summary>
/// Read a row from the specified reader into the provided userData object
/// </summary>
/// <param name="reader"></param>
private UserItemData ReadRow(IDataReader reader)
{
var userData = new UserItemData();
userData.Key = reader.GetString(0);
userData.UserId = reader.GetGuid(1);
if (!reader.IsDBNull(2))
{
userData.Rating = reader.GetDouble(2);
}
userData.Played = reader.GetBoolean(3);
userData.PlayCount = reader.GetInt32(4);
userData.IsFavorite = reader.GetBoolean(5);
userData.PlaybackPositionTicks = reader.GetInt64(6);
if (!reader.IsDBNull(7))
{
userData.LastPlayedDate = reader.GetDateTime(7).ToUniversalTime();
}
return userData;
}